Initial Commit
This commit is contained in:
35
api/app/main.py
Normal file
35
api/app/main.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/python
|
||||
import logging
|
||||
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
|
||||
from helpers.database import db
|
||||
from swagger import create_api
|
||||
from settings import config
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="%(asctime)s %(name)-12s %(levelname)-8s %(message)s",
|
||||
datefmt="%m-%d %H:%M",
|
||||
handlers=[logging.FileHandler(config.DASHBOARD_LOG), logging.StreamHandler()], # noqa
|
||||
)
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) # noqa
|
||||
|
||||
app.config.update(
|
||||
SQLALCHEMY_DATABASE_URI=config.SQLALCHEMY_DATABASE_URI,
|
||||
DEBUG=config.DEBUG
|
||||
)
|
||||
db.init_app(app)
|
||||
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
create_api(
|
||||
app=app,
|
||||
port="5000",
|
||||
host="localhost",
|
||||
api_prefix=config.API_PREFIX_STRING,
|
||||
custom_swagger=config.CUSTOM_SWAGGER
|
||||
)
|
||||
Reference in New Issue
Block a user