-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
37 lines (26 loc) · 878 Bytes
/
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
from flask_api import FlaskAPI
from flask_mysqldb import MySQL
from envparse import env
from lib.session import Session
app = FlaskAPI(__name__)
# Configure MySQL
app.config['MYSQL_HOST'] = env('MYSQL_HOST', cast=str)
app.config['MYSQL_USER'] = env('MYSQL_USER', cast=str)
app.config['MYSQL_PASSWORD'] = env('MYSQL_PASSWORD', cast=str)
app.config['MYSQL_DB'] = env('MYSQL_DB', cast=str)
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
# Initialise MySQL
mysql = MySQL(app)
@app.route('/login', methods=['POST'])
def login():
return Session.login(mysql=mysql)
@app.route('/logout', methods=['POST'])
def logout():
return Session.logout()
@app.route('/session')
@Session.check_auth
def session():
return Session.get_session_data()
if __name__ == '__main__':
app.secret_key = env('SESSION_SECRET_KEY', cast=str)
app.run(debug=env('DEBUG', cast=bool))