From 0500508a8e97b0d2e57c79b148c4e429234f33d5 Mon Sep 17 00:00:00 2001 From: Scobiform Date: Wed, 17 Apr 2024 15:51:35 +0200 Subject: [PATCH] feat: basic jinja2 template --- start.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/start.py b/start.py index 196869b..d3b32ad 100644 --- a/start.py +++ b/start.py @@ -13,6 +13,25 @@ # Quart app app = Quart(__name__) +config = None + +# Html header jinja2 template +html_header = ''' + + + + '''+config['app_name']+''' + + + + +''' + +# Html footer jinja2 template +html_footer = ''' + + +''' # Async setup function to load configs and create secrets @app.before_serving @@ -41,6 +60,8 @@ async def setup_app(): @app.route('/') async def home(): + header = html_header + footer = html_footer if 'access_token' in session: # Initialize Mastodon with the access token mastodon = Mastodon( @@ -48,13 +69,13 @@ async def home(): api_base_url=config['instance_url'] ) user = mastodon.account_verify_credentials() - return f''' + return header+f''' Logged in successfully!
Logout
Username: {user['username']}
- ''' - return 'Login with Mastodon' + '''+footer + return header+'Login with Mastodon'+footer @app.route('/login') async def login():