Example #1
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(settings)

    DB.init_app(app)
    redis_store.init_app(app)
    routes.configure_routes(app)
    configure_login(app)
    configure_logger(app)

    app.jinja_env.filters["json"] = json.dumps
    app.config["CDN_DOMAIN"] = settings.CDN_URL
    app.config["CDN_HTTPS"] = True
    cdn.init_app(app)

    if not app.debug and not app.testing:
        configure_ssl_redirect(app)

    Limiter(app, key_func=get_ipaddr, global_limits=[settings.RATE_LIMIT], storage_uri=settings.REDIS_RATE_LIMIT)

    return app
Example #2
0
from flask import Flask, render_template_string
from flask.ext.cdn import CDN

app = Flask(__name__)

app.config["CDN_DOMAIN"] = "mycdnname.cloudfront.net"
app.config["CDN_DEBUG"] = True
app.config["CDN_HTTPS"] = True

CDN(app)


@app.route("/")
def index():
    template_str = """{{ url_for('static', filename="logo.png") }}"""
    return render_template_string(template_str)


if __name__ == "__main__":
    app.run(debug=True)