Created
September 2, 2021 10:09
-
-
Save perymerdeka/2ea95461791954b3be7fa395b18e3b24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask | |
from flask_mongoengine import MongoEngine | |
from projects.blog.api.routes import blog_api_blueprint | |
db = MongoEngine() | |
def create_app(): | |
app = Flask(__name__, static_url_path='') | |
# set config | |
app_settings = os.getenv('APP_SETTINGS') | |
app.config.from_object(app_settings) | |
# setup extension | |
db.init_app(app) | |
app.register_blueprint(blueprint=blog_api_blueprint) | |
# shell context for flask cli | |
@app.shell_context_processor | |
def ctx(): | |
return {'app': app, 'db': db} | |
return app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment