From f12e35507d5d32fc596508204b1d5797ad01645c Mon Sep 17 00:00:00 2001 From: Robert Metcalf <metcalfr@cardiff.ac.uk> Date: Fri, 19 Nov 2021 09:33:01 +0000 Subject: [PATCH] add basic flask server and main template based on home.html --- .gitignore | 2 ++ main.py | 11 +++++++++++ templates/home.html | 2 ++ home.html => templates/main.html | 7 +++++-- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 main.py create mode 100644 templates/home.html rename home.html => templates/main.html (84%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38da6d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +.vscode/ diff --git a/main.py b/main.py new file mode 100644 index 0000000..e4e1c86 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +from flask import Flask, request, render_template + +app = Flask(__name__) + +@app.route("/", methods = ["GET"]) +def home(): + if request.method == "GET": + return render_template("home.html") + +if __name__ == "__main__": + app.run(debug = True) diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..214431d --- /dev/null +++ b/templates/home.html @@ -0,0 +1,2 @@ +{% extends "main.html" %} +{% block title %}Home{% endblock %} \ No newline at end of file diff --git a/home.html b/templates/main.html similarity index 84% rename from home.html rename to templates/main.html index e839908..56b139e 100644 --- a/home.html +++ b/templates/main.html @@ -12,7 +12,7 @@ "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> - <title>Hello</title> + <title>{% block title %}{% endblock %} - Tramshed Workspaces</title> </head> <div class="parallax"> @@ -26,4 +26,7 @@ <li><a href="#contactUs">Contact Us</a></li> <li style="float:right"><a class="active" href="#about">About</a></li> </ul> - </nav><br><br><br> + </nav> + {% block mainBlock %}{% endblock %} + </body> +</html> -- GitLab