Add ability to test http functions with postman like interface
This commit is contained in:
14
app.py
14
app.py
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user