-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsitebuilder.py
More file actions
37 lines (30 loc) · 843 Bytes
/
sitebuilder.py
File metadata and controls
37 lines (30 loc) · 843 Bytes
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
import sys
from flask import Flask, render_template, url_for
from flask_flatpages import FlatPages
from flask_frozen import Freezer
#
#
DEBUG = True
FLATPAGES_AUTO_RELOAD = DEBUG
FLATPAGES_EXTENSION = '.md'
app = Flask(__name__)
app.config.from_object(__name__)
pages = FlatPages(app)
freezer = Freezer(app)
@app.route('/')
def index():
return render_template('index.html', pages=pages)
@app.route('/<path:path>.html')
def page(path):
print("View function activated!")
page = pages.get_or_404(path)
return render_template('page.html', page=page)
@freezer.register_generator
def pagelist():
for page in pages:
yield url_for('page', path=page.path)
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == 'build':
freezer.freeze()
else:
app.run(host='0.0.0.0', port=5001)