Skip to content

Commit

Permalink
feat: basic jinja2 template
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent c5c58cf commit 0500508
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@

# Quart app
app = Quart(__name__)
config = None

# Html header jinja2 template
html_header = '''
<!DOCTYPE html>
<html>
<head>
<title>'''+config['app_name']+'''</title>
<script src="//unpkg.com/force-graph"></script>
<link rel="stylesheet" href="static/style.css">
</head>
<body>
'''

# Html footer jinja2 template
html_footer = '''
</body>
</html>
'''

# Async setup function to load configs and create secrets
@app.before_serving
Expand Down Expand Up @@ -41,20 +60,22 @@ 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(
access_token=session['access_token'],
api_base_url=config['instance_url']
)
user = mastodon.account_verify_credentials()
return f'''
return header+f'''
Logged in successfully! <br>
<a href="/logout">Logout</a><br>
Username: {user['username']}
<br>
'''
return '<a href="/login">Login with Mastodon</a>'
'''+footer
return header+'<a href="/login">Login with Mastodon</a>'+footer

@app.route('/login')
async def login():
Expand Down

0 comments on commit 0500508

Please sign in to comment.