From d31a0fbef37a0393515e4aac05dc466886f35114 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Fri, 20 Feb 2026 09:44:43 +0100 Subject: [PATCH] Modifica funzione lettura template per documentazione --- app.py | 18 +++++------------- templates/doc.html | 9 ++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app.py b/app.py index c63d285..2efec36 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,4 @@ -from flask import Flask, jsonify, request +from flask import Flask, jsonify, request, render_template compiti = [ {"id": 1, "descrizione": "Compito matematica"}, @@ -13,20 +13,12 @@ app = Flask(__name__) @app.route("/", methods=["GET"]) def home(): html = "

Home page API REST Compiti

ciao, 3cx merda

" - html += "Documentazione" + html += "Documentazione" return html, 200 -@app.route("/", 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("/doc", methods=["GET"]) +def get_doc(): + return render_template("doc.html"), 200 @app.route("/compiti", methods=["GET"]) def get_compiti(): diff --git a/templates/doc.html b/templates/doc.html index acaa0e9..4970cec 100644 --- a/templates/doc.html +++ b/templates/doc.html @@ -1 +1,8 @@ -haiiiii :3 \ No newline at end of file + + + Documentazione + + + haiiiii :3 + +