-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
30 lines (24 loc) · 939 Bytes
/
run.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
from msr import app
from msr import db, data_base
from msr.dao import User, Repository
import logging
CREATE_DB_EMPTY = False
# Remove all handlers associated with the root logger object.
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%d/%m/%Y %H:%M:%S',
filename='logs/my_app.log', filemode='w')
try:
if CREATE_DB_EMPTY:
db.drop_all()
db.create_all()
db.session.commit()
print(f'Data base {data_base} created with success!!')
else:
print(f'Data base {data_base} load successfully!')
logging.info("Application started successfully!")
except Exception as e:
print(f'Error creating {data_base} - {e}')
logging.error("Exception occurred", exc_info=True)
if __name__ == '__main__':
app.run(debug=True)