Aggiunta funzione templates
This commit is contained in:
12
app.py
12
app.py
@@ -15,6 +15,18 @@ def home():
|
|||||||
html += "<a href=\"/doc.html\">Documentazione</a>"
|
html += "<a href=\"/doc.html\">Documentazione</a>"
|
||||||
return html, 200
|
return html, 200
|
||||||
|
|
||||||
|
@app.route("/<path:filename>", methods=["GET"])
|
||||||
|
def template(filename):
|
||||||
|
if not filename.endswith(".html"):
|
||||||
|
return "File non valido", 404
|
||||||
|
try:
|
||||||
|
read_file = open(f"templates/{filename}", "r")
|
||||||
|
content = read_file.read()
|
||||||
|
read_file.close()
|
||||||
|
return content, 200
|
||||||
|
except FileNotFoundError:
|
||||||
|
return "File non trovato", 404
|
||||||
|
|
||||||
@app.route("/compiti", methods=["GET"])
|
@app.route("/compiti", methods=["GET"])
|
||||||
def get_compiti():
|
def get_compiti():
|
||||||
return jsonify(compiti), 200
|
return jsonify(compiti), 200
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
haiiiii :3
|
||||||
Reference in New Issue
Block a user