From f6cbfcff7792d9c6f2f5facf525c7e4a03b73bcc Mon Sep 17 00:00:00 2001 From: "Wortman, Elliot (UG - Comp Sci & Elec Eng)" <ew00710@surrey.ac.uk> Date: Thu, 16 Nov 2023 15:53:25 +0000 Subject: [PATCH] Flask backend return index.html & values endpoint Specified custom static & template folder for compatibility with `npm run build` --- .gitignore | 2 ++ app.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 app.py diff --git a/.gitignore b/.gitignore index 38adffa..96a147a 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ coverage *.njsproj *.sln *.sw? + +__pycache__/ diff --git a/app.py b/app.py new file mode 100644 index 0000000..688a103 --- /dev/null +++ b/app.py @@ -0,0 +1,14 @@ +from flask import Flask, jsonify, render_template +from flask_cors import CORS + +app = Flask(__name__, static_folder="./dist/assets", template_folder="./dist") +CORS(app) + +@app.route("/") +def main(): + return render_template("index.html") + +@app.route("/values") +def values(): + values = [{"N": 10}, {"P": 11}, {"K": 12}, {"T": 5}, {"H": 6}, {"M": 7}] + return jsonify(values) -- GitLab