-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
66 lines (51 loc) · 1.62 KB
/
server.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
61
62
63
64
65
66
from flask import *
from datetime import timedelta
from utils import *
from flask_caching import Cache
from dotenv import dotenv_values
from api.api import api
from auth.auth import auth
from dashboard.dashboard import dashboard
import time
import logging
config = dotenv_values(".env")
app = Flask(__name__, template_folder='views', static_folder='assets', static_url_path='/assets')
app.secret_key = config['secret_key']
cache = Cache(app,config={'CACHE_TYPE': 'simple'})
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app.register_blueprint(api, url_prefix='/api')
app.register_blueprint(auth)
app.register_blueprint(dashboard, url_prefix='/dashboard')
@app.before_request
def make_session_permanent():
session.permanent = True
app.permanent_session_lifetime = timedelta(hours=5)
@app.route('/', methods=['GET', 'POST'])
@cache.cached(timeout=200)
def index():
a = get_allFrequency()
b = json.loads(a)
allValue = {
"frequencyRegistered": len(b),
"peopleRegistered": 31,
"frequencyAviable": 999-int(len(b))
}
return render_template('index.html', value=allValue)
@app.route('/sitemap.xml', methods=['GET', 'POST'])
def sitemap():
return send_from_directory(app.static_folder, 'sitemap.xml')
@app.errorhandler(404)
def page_not_found(e):
# note that we set the 404 status explicitly
return render_template('index.html'), 404
def start_site():
try:
app.debug = False
app.run(host='0.0.0.0', port=53056, threaded=True)
except Exception as e:
print(e)
time.sleep(2)
start_site()
if __name__ == '__main__':
start_site()