Exemplo n.º 1
0
def create_app(**config):
    app = Flask('iatilib.frontend')

    app.config.update(config)

    Heroku(app)

    if "REDISTOGO_URL" in os.environ:
        app.config.update({
            'RQ_DEFAULT_HOST': app.config["REDIS_HOST"],
            'RQ_DEFAULT_PORT': app.config["REDIS_PORT"],
            'RQ_DEFAULT_PASSWORD': app.config['REDIS_PASSWORD']
        })

    db.app = app  # don't understand why I need to this
    db.init_app(app)
    redis.init_app(app)

    RQ(app)
    Markdown(app, extensions=['tables'])

    @app.route('/')
    def homepage():
        from flask import render_template
        with app.open_resource('docs/index.md') as f:
            contents = f.read()
        return render_template('doc.html', doc=contents)

    from .api1 import api

    app.register_blueprint(api, url_prefix="/api/1")
    return app
def create_app(**config):
    app = Flask("iatilib.frontend")

    app.config.update(config)

    if "SQLALCHEMY_DATABASE_URI" not in app.config:
        app.config["SQLALCHEMY_DATABASE_URI"] = os.environ["DATABASE_URL"]

    db.app = app  # don't understand why I need to this
    db.init_app(app)

    @app.route("/")
    def homepage():
        return app.send_static_file("index.html")

    from .api1 import api

    app.register_blueprint(api, url_prefix="/api/1")
    return app
Exemplo n.º 3
0
def create_app(**config):
    app = Flask('iatilib.frontend')

    app.config.update(config)

    Heroku(app)

    if "REDISTOGO_URL" in os.environ:
        app.config.update({
            'RQ_DEFAULT_HOST': app.config["REDIS_HOST"],
            'RQ_DEFAULT_PORT': app.config["REDIS_PORT"],
            'RQ_DEFAULT_PASSWORD': app.config['REDIS_PASSWORD']
        })

    db.app = app  # don't understand why I need to this
    db.init_app(app)
    redis.init_app(app)

    RQ(app)
    Markdown(app, extensions=['tables'])

    @app.route('/')
    def homepage():
        from flask import render_template
        with app.open_resource('docs/index.md') as f:
            contents = f.read()
        return render_template('doc.html', doc=contents)

    @app.route('/error')
    def error():
        from flask import render_template
        with app.open_resource('docs/error.md') as f:
            contents = f.read()
        return render_template('doc.html', doc=contents)

    from .api1 import api

    app.register_blueprint(api, url_prefix="/api/1")
    return app
Exemplo n.º 4
0
def register_extensions(app):
    db.init_app(app)
    rq.init_app(app)
    CORS(app)
    migrate.init_app(app, db)