-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.py
48 lines (29 loc) · 1002 Bytes
/
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
import os
from flask import Flask, Blueprint
from flask_restful import Api
from flask_jwt import JWT
from src.utils.security import authenticate, identity
from src.models.basemodel import db
def initdb(flask_app):
db.init_app(flask_app)
def create_app():
from src.routes.api import routes, admin_routes
flask_app = Flask(__name__)
flask_app.config.from_pyfile('config.py')
bp = Blueprint('api', __name__, static_url_path="assets")
admin_bp = Blueprint('admin', __name__, static_url_path="assets")
api = Api(bp)
admin = Api(admin_bp)
routes(api)
admin_routes(admin)
flask_app.register_blueprint(bp, url_prefix="/api/v1")
flask_app.register_blueprint(admin_bp, url_prefix="/api/v1/admin")
JWT(flask_app, authenticate, identity) # /auth
@flask_app.route('/')
def index():
return 'Welcome to Flask Rest API Setup!'
initdb(flask_app)
return flask_app
app = create_app()
if __name__ == "__main__":
app.run()