Skip to content

Instantly share code, notes, and snippets.

@perymerdeka
Created September 2, 2021 10:09
Show Gist options
  • Save perymerdeka/2ea95461791954b3be7fa395b18e3b24 to your computer and use it in GitHub Desktop.
Save perymerdeka/2ea95461791954b3be7fa395b18e3b24 to your computer and use it in GitHub Desktop.
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