-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (39 loc) · 1.38 KB
/
main.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
import os
from flask import Flask
from flask_restful import Api
from flask_jwt_extended import JWTManager
from flask_cors import CORS
from dotenv import load_dotenv
from services import DBService
from middleware import check_token_expiry
from services import email_service
from resources import Login, Register, GetUser, Onboarding, AddTask, SendEmail, Dashboard
from resources import GetTasks, UpdateStatus, UpdateTaskData, ListUsers, DeleteTask
load_dotenv('.env')
app = Flask(__name__)
api = Api(app)
# Config
app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY')
# initialization
CORS(app)
env = os.getenv('ENV')
jwt = JWTManager(app)
db_service = DBService(env)
email = email_service()
# Resources
api.add_resource(Login, '/api/login')
api.add_resource(Register, '/api/register')
api.add_resource(GetUser, '/api/get-user')
api.add_resource(Onboarding, '/api/onboarding')
api.add_resource(AddTask, '/api/tasks/add-task')
api.add_resource(GetTasks, '/api/tasks/get-tasks')
api.add_resource(UpdateStatus, '/api/tasks/update-status')
api.add_resource(UpdateTaskData, '/api/tasks/update-task-data')
api.add_resource(ListUsers, '/api/list-users')
api.add_resource(DeleteTask, '/api/tasks/delete-task')
api.add_resource(SendEmail, '/api/task-notify')
api.add_resource(Dashboard, '/api/dashboard')
# middleware
app.before_request(check_token_expiry)
if __name__ == '__main__':
app.run(debug=True)