-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.py
45 lines (32 loc) · 1 KB
/
static.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
40
41
42
43
44
45
import sys
from os.path import join
import settings
from flask import Flask
from jamstack.api.template import base_context, generate
from livereload import Server
context = base_context()
context.update({
"info": settings.info
})
def main(args):
def gen():
generate('index.html', join(
settings.OUTPUT_FOLDER, 'index.html'), **context)
if len(args) > 1 and args[1] == '--server':
app = Flask(__name__)
# remember to use DEBUG mode for templates auto reload
# https://github.com/lepture/python-livereload/issues/144
app.debug = True
server = Server(app.wsgi_app)
# run a shell command
# server.watch('.', 'make static')
# run a function
server.watch('.', gen, delay=5)
server.watch('*.py')
# output stdout into a file
# server.watch('style.less', shell('lessc style.less', output='style.css'))
server.serve()
else:
gen()
if __name__ == '__main__':
main(sys.argv)