forked from 2023-Winter-Bootcamp-TeamH/buyself-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
53 lines (39 loc) · 1.3 KB
/
app.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
from flask import Flask
from flask_migrate import Migrate
from flask_restx import Api
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
from prometheus_flask_exporter import PrometheusMetrics
from config import DatabaseConfig
import logging
db = SQLAlchemy()
migrate = Migrate()
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
logging.info("Setting LOGLEVEL to INFO")
metrics = PrometheusMetrics(app)
metrics.info("app_info", "App Info, this can be anything you want", version="1.0.3")
def create_app():
app.config['JSON_AS_ASCII'] = False
app.config.from_object(DatabaseConfig)
# CORS
CORS(app, resources={r'*': {'origins': '*'}})
# ORM
db.init_app(app)
migrate.init_app(app, db)
# API Swagger
api = Api(
app,
version='v1',
title="Silicon Project's API Server",
description="Dessert API Server",
terms_url="/",
contact="[email protected]",
license="MIT",
)
from controller import searchController,listController,predictController, paymentController
api.add_namespace(searchController.Products, '/')
api.add_namespace(listController.Products, '/')
api.add_namespace(predictController.Products, '/')
api.add_namespace(paymentController.Products, '/')
return app