forked from anitab-org/bridge-in-tech-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
98 lines (74 loc) · 3.16 KB
/
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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import os
from flask import Flask, jsonify
from flask_migrate import Migrate, MigrateCommand
from flask_cors import CORS
from config import get_env_config
cors = CORS()
def create_app(config_filename: str) -> Flask:
# instantiate the app
app = Flask(__name__, instance_relative_config=True)
# setup application environment
app.config.from_object(config_filename)
app.url_map.strict_slashes = False
from app.database.sqlalchemy_extension import db
db.init_app(app)
from app.database.models.ms_schema.user import UserModel
from app.database.models.ms_schema.mentorship_relation import (
MentorshipRelationModel,
)
from app.database.models.ms_schema.tasks_list import TasksListModel
from app.database.models.ms_schema.task_comment import TaskCommentModel
from app.database.models.bit_schema.organization import OrganizationModel
from app.database.models.bit_schema.program import ProgramModel
from app.database.models.bit_schema.user_extension import UserExtensionModel
from app.database.models.bit_schema.personal_background import (
PersonalBackgroundModel,
)
from app.database.models.bit_schema.mentorship_relation_extension import (
MentorshipRelationExtensionModel,
)
migrate = Migrate(app, db)
cors.init_app(app, resources={r"*": {"origins": "http://localhost:3000"}})
from app.api.jwt_extension import jwt
jwt.init_app(app)
from app.api.bit_extension import api
api.init_app(app)
from app.api.mail_extension import mail
mail.init_app(app)
return app
application = create_app(get_env_config())
@application.before_first_request
def create_tables():
from app.database.sqlalchemy_extension import db
from app.database.models.ms_schema.user import UserModel
from app.database.models.ms_schema.mentorship_relation import (
MentorshipRelationModel,
)
from app.database.models.ms_schema.tasks_list import TasksListModel
from app.database.models.ms_schema.task_comment import TaskCommentModel
from app.database.models.bit_schema.organization import OrganizationModel
from app.database.models.bit_schema.program import ProgramModel
from app.database.models.bit_schema.user_extension import UserExtensionModel
from app.database.models.bit_schema.personal_background import (
PersonalBackgroundModel,
)
from app.database.models.bit_schema.mentorship_relation_extension import (
MentorshipRelationExtensionModel,
)
db.create_all()
@application.shell_context_processor
def make_shell_context():
return {
"db": db,
"UserModel": UserModel,
"MentorshipRelationModel": MentorshipRelationModel,
"TaskListModel": TasksListModel,
"TaskCommentModel": TaskCommentModel,
"OrganizationModel": OrganizationModel,
"ProgramModel": ProgramModel,
"UserExtensionModel": UserExtensionModel,
"PersonalBackgroundModel": PersonalBackgroundModel,
"MentorshipRelationExtensionModel": MentorshipRelationExtensionModel,
}
if __name__ == "__main__":
application.run(port=5000)