Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Trevor Austin
/
mpcs-52553-austin-winter-2021
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ae73ab68
authored
Feb 10, 2021
by
Trevor Austin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add example of template processing (not used in assignment)
parent
e26295c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
week_5/exercise_5/app.py
week_5/exercise_5/templates/exampleTemplate.html
week_5/exercise_5/app.py
View file @
ae73ab68
...
...
@@ -10,7 +10,7 @@ app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
# sample_chats = {
# 1: {
# "authorized_users": {
# "
session_token_0
": {"username": "Alice", "expires": "2020-02-15T20:53:15Z"},
# "
as3215jhkg231hjgkl4123
": {"username": "Alice", "expires": "2020-02-15T20:53:15Z"},
# "session_token_1": {"username": "Bob", "expires": "2020-02-15T20:57:22Z"}
# },
# "magic_key": "some_really_long_key_value"
...
...
@@ -52,6 +52,14 @@ def auth():
def
chat
():
return
app
.
send_static_file
(
'chat.html'
)
@app.route
(
'/exampleTemplate'
)
def
example
():
return
render_template
(
'exampleTemplate.html'
,
title
=
"My Cool Title!"
,
header
=
"My cool header!"
)
# -------------------------------- API ROUTES ----------------------------------
...
...
@@ -70,7 +78,7 @@ def create ():
def
authenticate
():
# TODO: check if the request body contains a chat_id and the correct magic_key for that chat
# TODO: also send a username
return
{
"session_token"
:
"
some_token_value
"
}
return
{
"session_token"
:
"
as3215jhkg231hjgkl4123
"
}
@app.route
(
'/api/messages'
,
methods
=
[
'GET'
,
'POST'
])
def
messages
():
...
...
week_5/exercise_5/templates/exampleTemplate.html
0 → 100644
View file @
ae73ab68
<html>
<head>
<title>
{{title}}
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"static/style.css"
></link>
<script
src=
"static/script.js"
></script>
</head>
<body>
<div
class=
"container"
>
<h3>
{{header}}
</h3>
</div>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment