-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
53 lines (46 loc) · 1.51 KB
/
run.py
File metadata and controls
53 lines (46 loc) · 1.51 KB
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
# AmazRT - Parcel Management System
# First semester Technical Degree project
# Copyright (c) 2021 - 2022
# - Meryem KAYA @MeryemKy
# - Alexis LEBEL @Alestrio
# - Malo LEGRAND @HoesMaaad
import os
from flask_login import LoginManager
from flask_wtf import CSRFProtect
from flask_qrcode import QRcode
from flask import session
from requests.auth import HTTPBasicAuth
from application import app, service
from application.data.entities.people.Customer import Customer
from application.data.entities.people.Operator import Operator
from application.data.entities.people.Supplier import Supplier
login = LoginManager()
@login.user_loader
def load_user(u_login):
user = {
'as_customer': Customer.fromdict(service.getOne(Customer(), u_login)),
'as_operator': Operator.fromdict(service.getOne(Operator(), u_login)),
'as_supplier': Supplier.fromdict(service.getOne(Supplier(), u_login))
}
for i in user:
if user[i] is not None:
return user[i]
return None
if __name__ == "__main__":
csrf = CSRFProtect(app)
SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY
app.config['WTF_CSRF_SECRET_KEY'] = SECRET_KEY
csrf.init_app(app)
login.init_app(app)
QRcode(app)
app.run(debug=True, port=80)
else:
csrf = CSRFProtect(app)
SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY
app.config['WTF_CSRF_SECRET_KEY'] = SECRET_KEY
csrf.init_app(app)
login.init_app(app)
QRcode(app)
application = app