-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrontend.py
37 lines (29 loc) · 862 Bytes
/
frontend.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
import os
from flask import Blueprint, render_template, send_file
from server import csrf
from server.decorators import api
frontend = Blueprint('frontend', __name__, url_prefix='')
@frontend.route('/')
def index():
gitinfo = ['error\n', 'error\n']
gi = 'gitinfo.txt'
if os.path.isfile(gi):
with open(gi, 'r') as f:
gitinfo = f.readlines()
else: print "no file: {0}".format(os.getcwd())
return render_template('btjs3/client.html', gitinfo=gitinfo)
# Serve the js from here until nginx handles the static content
@frontend.route('/js/<path:path>')
def static_proxy(path):
path = os.path.join('templates/btjs3/js', path)
return send_file(path)
@csrf.include
@frontend.route('/csrf')
@api
def csrf_token():
"""
Method: GET
API Fields:
None
"""
return dict(token=csrf._get_token())