-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4956 from open-formulieren/feature/4908-json-regi…
…stration-backend Feature/4908 json registration backend
- Loading branch information
Showing
35 changed files
with
1,637 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.8' | ||
|
||
name: json-dump | ||
|
||
services: | ||
flask_app: | ||
build: ./json-dump | ||
ports: | ||
- "80:80" | ||
volumes: | ||
- ./json-dump/:/app/ | ||
|
||
networks: | ||
open-forms-dev: | ||
name: open-forms-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Use the official Python image from the Docker Hub | ||
FROM python:3.12-slim | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app | ||
|
||
# Install the dependencies | ||
RUN pip install Flask | ||
|
||
# Make port 80 available to the world outside this container | ||
EXPOSE 80 | ||
|
||
# Run app.py when the container launches | ||
CMD ["python", "app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# JSON dump registration plugin | ||
|
||
The `docker-compose.json-dump.yml` compose file is available to run a mock service intended | ||
to simulate a receiving server to test the JSON dump registration backend plugin. It contains an | ||
endpoint for sending json data (`json_plugin`) and testing the connection (`test_connection`). | ||
|
||
The `json_plugin` endpoint returns a confirmation message that the data was received, together with the | ||
received data. The `test_connection` endpoint just returns an 'OK' message. | ||
|
||
## docker compose | ||
|
||
Start an instance in your local environment from the parent directory: | ||
|
||
```bash | ||
docker compose -f docker-compose.json-dump.yml up -d | ||
``` | ||
|
||
This starts a flask application at http://localhost:80/ with the endpoints `json_plugin` and `test_connection`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
|
||
from flask import Flask, jsonify, request | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/json_plugin", methods=["POST"]) | ||
def json_plugin_post(): | ||
data = request.get_json() | ||
|
||
app.logger.info(f"Data received: {data}") | ||
|
||
message = "No data" if data is None else "Data received" | ||
return jsonify({"message": message, "data": json.loads(data)}), 201 | ||
|
||
|
||
@app.route("/test_connection", methods=["GET"]) | ||
def test_connection(): | ||
return jsonify({"message": "OK"}), 200 | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=80, debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.