This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (38 loc) · 1.72 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_restx import Api
from flask_cors import CORS
def create_app():
app = Flask(__name__)
app.config['TESTING'] = True
app.app_context().push()
from application.config import LocalDevelopmentConfig
if os.getenv('ENV',"development")=="production":
raise Exception("Currently no production config is setup.")
else:
print("Starting Local Development")
app.config.from_object(LocalDevelopmentConfig)
from application.database import db
db.init_app(app)
from application.views.viewsCustomer import viewsCustomer
from application.views.viewsDelExe import viewsDelExe
from application.views.viewsStoreMng import viewsStoreMng
from application.views.viewsDeveloper import viewsDeveloper
from application.views.auth import auth
app.register_blueprint(viewsCustomer, url_prefix='/')
app.register_blueprint(viewsDelExe, url_prefix='/')
app.register_blueprint(viewsStoreMng, url_prefix='/')
app.register_blueprint(viewsDeveloper, url_prefix='/')
app.register_blueprint(auth, url_prefix='/')
CORS(app, resources={r"/api/*": {"origins": "*"}})
from flask import Blueprint
from application.api import CategoryAPI, ProductAPI
api_bp = Blueprint('api', __name__)
api = Api(api_bp, version='1.0', title='API', description='API documentation')
api.add_resource(CategoryAPI, '/categories', '/categories/<int:category_id>')
api.add_resource(ProductAPI, '/products', '/products/<int:product_id>', '/products/<int:flag>/<int:category_id>')
app.register_blueprint(api_bp, url_prefix='/api')
return app,api
app,api=create_app()
if __name__=='__main__':
app.run(host='0.0.0.0',debug=True,port=8080)