def create_app(testing=False): app = FlaskBase( __name__, "snapcraft.io", favicon_url="https://assets.ubuntu.com/v1/fdc99abe-ico_16px.png", template_404="404.html", template_folder="../templates", static_folder="../static", ) app.config.from_object("webapp.config") app.testing = testing if not testing: init_extensions(app) talisker.requests.configure(webapp.api.sso.api_session) talisker.requests.configure(webapp.helpers.api_session) talisker.requests.configure(webapp.helpers.api_publisher_session) app.config.from_object("webapp.configs." + app.config["WEBAPP"]) set_handlers(app) if app.config["WEBAPP"] == "snapcraft": init_snapcraft(app) else: init_brandstore(app) return app
def create_app(testing=False): app = flask.Flask(__name__, template_folder="../templates", static_folder="../static") app.config.from_object("webapp.config") app.testing = testing app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) app.url_map.strict_slashes = False app.url_map.converters["regex"] = helpers.RegexConverter if not testing: init_extensions(app) talisker.flask.register(app) talisker.requests.configure(webapp.api.blog.api_session) talisker.requests.configure(webapp.api.dashboard.api_session) talisker.requests.configure(webapp.api.sso.api_session) talisker.logs.set_global_extra({"service": "snapcraft.io"}) app.config.from_object("webapp.configs." + app.config["WEBAPP"]) set_handlers(app) if app.config["WEBAPP"] == "snapcraft": init_snapcraft(app, testing) else: init_brandstore(app) return app
def create_app(testing=False): app = flask.Flask( __name__, template_folder='../templates', static_folder='../static') app.config.from_object('webapp.config') app.testing = testing app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) app.url_map.strict_slashes = False app.url_map.converters['regex'] = helpers.RegexConverter if not testing: talisker.flask.register(app) prometheus_flask_exporter.PrometheusMetrics( app, group_by_endpoint=True, buckets=[0.25, 0.5, 0.75, 1, 2], path=None ) init_extensions(app) app.config.from_object('webapp.configs.' + app.config['WEBAPP']) set_handlers(app) if app.config['WEBAPP'] == 'snapcraft': init_snapcraft(app) else: init_brandstore(app) return app
def create_app(testing=False): app = flask.Flask( __name__, template_folder="../templates", static_folder="../static" ) app.config.from_object("webapp.config") app.testing = testing app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) app.url_map.strict_slashes = False app.url_map.converters["regex"] = helpers.RegexConverter if not testing: talisker.flask.register(app) init_extensions(app) app.config.from_object("webapp.configs." + app.config["WEBAPP"]) set_handlers(app) if app.config["WEBAPP"] == "snapcraft": init_snapcraft(app, testing) else: init_brandstore(app) return app
def create_app(testing=False): app = flask.Flask(__name__, template_folder="../templates", static_folder="../static") app.config.from_object("webapp.config") app.testing = testing app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) app.url_map.strict_slashes = False app.url_map.converters["regex"] = helpers.RegexConverter if not testing: talisker.flask.register(app) init_extensions(app) app.config.from_object("webapp.configs." + app.config["WEBAPP"]) set_handlers(app) if app.config["WEBAPP"] == "snapcraft": init_snapcraft(app, testing) else: init_brandstore(app) return app
def create_app(testing=False): app = flask.Flask( __name__, template_folder="../templates", static_folder="../static" ) app.config.from_object("webapp.config") app.testing = testing app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) app.url_map.strict_slashes = False app.url_map.converters["regex"] = helpers.RegexConverter if not testing: talisker.flask.register(app) prometheus_flask_exporter.PrometheusMetrics( app, group_by_endpoint=True, buckets=[0.25, 0.5, 0.75, 1, 2], path=None, ) init_extensions(app) app.config.from_object("webapp.configs." + app.config["WEBAPP"]) set_handlers(app) if app.config["WEBAPP"] == "snapcraft": init_snapcraft(app) else: init_brandstore(app) return app
class RegexConverter(BaseConverter): def __init__(self, url_map, *items): super(RegexConverter, self).__init__(url_map) self.regex = items[0] app = flask.Flask(__name__, template_folder="../templates", static_folder="../static") app.before_request(prepare_redirects()) app.url_map.strict_slashes = False app.url_map.converters["regex"] = RegexConverter app.wsgi_app = ProxyFix(app.wsgi_app) if app.debug: app.wsgi_app = DebuggedApplication(app.wsgi_app) talisker.flask.register(app) talisker.logs.set_global_extra({"service": "jp.ubuntu.com"}) set_handlers(app) app.register_blueprint(jp_website) blog_views = BlogViews(blog_title="Ubuntu blog", tag_ids=[3184]) app.register_blueprint(build_blueprint(blog_views), url_prefix="/blog") if __name__ == "__main__": app.run(host="0.0.0.0")