-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (31 loc) · 1.05 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, render_template, send_from_directory
from model.startpage import get_startpage
from model.aboutpage import get_aboutpage
from model.articlepage import get_articlepages
from model.sitesettings import get_sitesettings
app = Flask(__name__)
# Load global site settings
sitesettings = get_sitesettings()
# Load all articles
articles = get_articlepages()
# Add route to Assets
@app.route('/assets/<path:path>')
def assets(path):
return send_from_directory('assets', path)
# Website routes
@app.route('/')
def index():
model = get_startpage()
model.sitesettings = sitesettings
return render_template('index.html.j2', model=model)
@app.route('/about')
def about():
model = get_aboutpage()
model.sitesettings = sitesettings
return render_template('about.html.j2', model=model)
@app.route('/article/<int:id>')
def article(id=id):
model = next((article for article in articles if article.id == id), None)
model.sitesettings = sitesettings
return render_template('article.html.j2', model=model)
app.run(debug=True)