From 76f77fdaddaedb80dd491660309b5b34ec3bb358 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 21 Dec 2023 19:41:55 +0100 Subject: [PATCH] draft: some ideas on the project structure --- src/app.py | 11 +++++------ src/public/css/style.css | 3 +++ src/routes/index.py | 13 +++++++++++++ src/routes/read.py | 13 +++++++++++++ src/templates/head.html | 12 ++++++++++++ src/templates/header.html | 1 + src/templates/index.html | 18 ++++++++++++++++++ src/templates/post.html | 1 + src/templates/read.html | 17 +++++++++++++++++ 9 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 src/public/css/style.css create mode 100644 src/routes/index.py create mode 100644 src/routes/read.py create mode 100644 src/templates/head.html create mode 100644 src/templates/header.html create mode 100644 src/templates/index.html create mode 100644 src/templates/post.html create mode 100644 src/templates/read.html diff --git a/src/app.py b/src/app.py index 924d3eb..d72c7c1 100644 --- a/src/app.py +++ b/src/app.py @@ -1,8 +1,7 @@ from flask import Flask +from routes.index import router as index +from routes.read import router as read -app = Flask(__name__) - - -@app.route("/") -def hello_world(): - return "

Hello, World!

" +app = Flask(__name__, static_url_path="/", static_folder="public") +app.register_blueprint(index, url_prefix="/") +app.register_blueprint(read, url_prefix="/read") diff --git a/src/public/css/style.css b/src/public/css/style.css new file mode 100644 index 0000000..f0437fa --- /dev/null +++ b/src/public/css/style.css @@ -0,0 +1,3 @@ +html { + font-family: "Courier New", Courier, monospace; +} diff --git a/src/routes/index.py b/src/routes/index.py new file mode 100644 index 0000000..694a71f --- /dev/null +++ b/src/routes/index.py @@ -0,0 +1,13 @@ +""" +Index page with a list of posts. +""" + +from flask import Blueprint, render_template + +router = Blueprint("index", __name__) + + +@router.route("") +def index() -> str: + """Index page""" + return render_template("index.html") diff --git a/src/routes/read.py b/src/routes/read.py new file mode 100644 index 0000000..2303b6a --- /dev/null +++ b/src/routes/read.py @@ -0,0 +1,13 @@ +""" +Read a specific post. +""" + +from flask import Blueprint, render_template + +router = Blueprint("read", __name__) + + +@router.route("") +def read() -> str: + """Read page""" + return render_template("read.html") diff --git a/src/templates/head.html b/src/templates/head.html new file mode 100644 index 0000000..6cf4630 --- /dev/null +++ b/src/templates/head.html @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/templates/header.html b/src/templates/header.html new file mode 100644 index 0000000..f3a8152 --- /dev/null +++ b/src/templates/header.html @@ -0,0 +1 @@ +
diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 0000000..1b35427 --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,18 @@ + + + + {% include "head.html" %} + Index + + + {% include "header.html" %} + + +

Welcome to the index page

+ + + + + {% include "post.html" %} + + diff --git a/src/templates/post.html b/src/templates/post.html new file mode 100644 index 0000000..dc1c977 --- /dev/null +++ b/src/templates/post.html @@ -0,0 +1 @@ + diff --git a/src/templates/read.html b/src/templates/read.html new file mode 100644 index 0000000..b145366 --- /dev/null +++ b/src/templates/read.html @@ -0,0 +1,17 @@ + + + + {% include "head.html" %} + Read + + {% include "header.html" %} + +

Welcome to the read page

+ + + + + + + +