Add ability to test http functions with postman like interface

This commit is contained in:
Peter Stockings
2023-12-16 19:55:51 +11:00
parent 8f94ae12ef
commit ab25d557f8
5 changed files with 86 additions and 96 deletions

14
app.py
View File

@@ -5,7 +5,7 @@ from jinja2_fragments import render_block
from flask_htmx import HTMX
import requests
from db import DataBase
from services import create_http_functions_view_model
from services import create_http_function_view_model, create_http_functions_view_model
app = Flask(__name__)
app.config.from_pyfile('config.py')
@@ -32,6 +32,7 @@ DEFAULT_SCRIPT = """async (req) => {
<td>${value}</td>
</tr>`)}
</table>
<pre>${JSON.stringify(req.body, null, 2)}</pre>
</div>`)
}"""
@@ -59,9 +60,14 @@ def map_isolator_response_to_flask_response(response):
def home():
return render_template("home.html", script=DEFAULT_SCRIPT)
@ app.route("/client", methods=["GET"])
def client():
return render_template("client.html")
@ app.route("/client/<function>", methods=["GET"])
def client(function):
http_function = db.get_http_function(function)
if not http_function:
return jsonify({'error': 'Function not found'}), 404
http_function = create_http_function_view_model(http_function)
return render_template("client.html", **http_function)
@ app.route("/dashboard", methods=["GET"])
def dashboard():