all repos — moviedb @ 876024d8b8e936cad742d208033d14c81e21cdbc

A Flask web-app to browse movie information from IMDb using imdbpy

moviedb/__init__.py

from flask import Flask, session, g
from flask_cors import CORS
from flask_sqlalchemy import SQLAlchemy
import os

db = SQLAlchemy()

def create_app():
    app = Flask(__name__)

    # Set the db_url variable or else it will read the env variable
    # or else environment variable DATABASE_URL will be used
    db_url=""
    if 'DATABASE_URL' in os.environ.keys():
        db_url = os.environ['DATABASE_URL']

    app.config['SQLALCHEMY_DATABASE_URI'] = db_url
    app.config['SECRET_KEY'] = os.environ['APP_CONFIG_SECRET_KEY']

    db.init_app(app)
    CORS(app)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app