From db93ff98409fac1c1a3742d0f81484c985d6d55c Mon Sep 17 00:00:00 2001 From: Linnnus Date: Wed, 20 Mar 2024 15:17:36 +0100 Subject: Add templating engine and index page --- app.py | 5 +++-- requirements.txt | 2 ++ views/base.html | 13 +++++++++++++ views/index.html | 7 +++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 views/base.html create mode 100644 views/index.html diff --git a/app.py b/app.py index 20932a8..e8bbc8b 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,10 @@ from bottle import Bottle, run +from bottle import jinja2_template as template app = Bottle() -@app.route('/hello') +@app.route("/") def hello(): - return "Hello World!" + return template("index") run(app, host='localhost', port=8080) diff --git a/requirements.txt b/requirements.txt index 7a4121d..6f7f942 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ bottle==0.12.25 +Jinja2==3.1.3 +MarkupSafe==2.1.5 diff --git a/views/base.html b/views/base.html new file mode 100644 index 0000000..9b364a8 --- /dev/null +++ b/views/base.html @@ -0,0 +1,13 @@ + + + + + + +
+
+
{% block content %}{% endblock %}
+ + + diff --git a/views/index.html b/views/index.html new file mode 100644 index 0000000..e98e8e5 --- /dev/null +++ b/views/index.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block content %} +

Index

+

Welcome to my awesome homepage.

+{% endblock %} + -- cgit v1.2.3