browser-go-api/app.py

57 lines
878 B
Python
Raw Normal View History

2019-09-25 02:50:25 +00:00
import os
from flask import Flask
2019-10-02 20:55:09 +00:00
# ! SQLAlchemy > Marshmallow - these must be imported in this order
2019-09-28 21:03:27 +00:00
from flask_sqlalchemy import SQLAlchemy
2019-10-02 03:09:46 +00:00
from flask_marshmallow import Marshmallow
2019-10-02 20:55:09 +00:00
2019-10-02 00:08:53 +00:00
from flask_migrate import Migrate
2019-09-25 02:50:25 +00:00
2019-10-02 20:55:09 +00:00
from flask_bcrypt import Bcrypt
from flask_cors import CORS
2019-09-25 02:50:25 +00:00
app = Flask(__name__)
2019-10-02 20:55:09 +00:00
CORS(app)
2019-09-25 02:50:25 +00:00
2019-09-28 21:03:27 +00:00
# config database
2019-10-04 18:24:11 +00:00
app_settings = os.getenv(
'APP_SETTINGS',
2019-10-04 22:00:47 +00:00
'config.DevelopmentConfig'
2019-10-04 18:24:11 +00:00
)
app.config.from_object(app_settings)
2019-09-28 21:03:27 +00:00
2019-10-04 22:00:47 +00:00
# init bcrypt
2019-10-02 20:55:09 +00:00
bcrypt = Bcrypt(app)
2019-09-28 21:03:27 +00:00
# init database
db = SQLAlchemy(app)
# init marshmallow
2019-10-02 03:09:46 +00:00
ma = Marshmallow(app)
2019-09-28 21:03:27 +00:00
2019-10-02 20:55:09 +00:00
# init all db models
2019-10-04 22:00:47 +00:00
import models
2019-10-02 20:55:09 +00:00
migrate = Migrate(app, db)
2019-09-28 21:03:27 +00:00
# dev server
2019-09-25 02:50:25 +00:00
DEBUG = True
PORT = 8000
2019-09-28 21:03:27 +00:00
# Routes
2019-09-25 02:50:25 +00:00
@app.route('/')
def hello_world():
return 'Hello World'
2019-10-04 22:00:47 +00:00
# Blue prints
from api.api import api
app.register_blueprint(api)
2019-10-04 18:24:11 +00:00
2019-09-25 02:50:25 +00:00
if __name__ == '__main__':
app.run(debug=DEBUG, port=PORT)