-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·60 lines (46 loc) · 1.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# coding: utf-8
import os
import logging
import fnmatch
import logging
from flask import Flask, send_from_directory, send_file, jsonify, redirect
# from google.appengine.api import users
from config import CONFIG
formatter = logging.Formatter(u'%(message)s')
logger = logging.getLogger()
if not logger.handlers:
handler = logging.StreamHandler()
else:
handler = logger.handlers[0]
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
# Create flask server
APP = Flask(__name__)
APP.debug = CONFIG[u"app"][u"env"]
# App routes.
INDEX_FILE = None
for f in os.listdir('./dist'):
if fnmatch.fnmatch(f, 'dev-index.html') or fnmatch.fnmatch(f, 'index.html'):
INDEX_FILE = u"/".join([u"dist", f])
# @APP.route('/logout')
# def force_logout():
# logout_url = users.create_logout_url('/')
# return redirect(logout_url)
@APP.route('/<path:path>')
def send_client(path):
logging.info("path: %s", path)
# logging.info("je viens d'etre appele")
"""
Handles client resources.
"""
return send_from_directory('dist/', path)
@APP.errorhandler(404)
def send_index(e):
"""
Redirect to client index file if not found.
"""
return send_file(INDEX_FILE, cache_timeout=-1)
# Finally register the Db API blueprint
if __name__ == "__main__":
APP.run(threaded=True, host=u"0.0.0.0", debug=True)