app = flask.Flask(__name__) app.jinja_env.filters['monthname'] = helpers.monthname app.url_map.strict_slashes = False app.url_map.converters['regex'] = helpers.RegexConverter if not app.debug: metrics = prometheus_flask_exporter.PrometheusMetrics( app, group_by_endpoint=True, buckets=[0.25, 0.5, 0.75, 1, 2], path=None ) metrics.start_http_server(port=9990, endpoint='/') apply_redirects = redirects.prepare_redirects( permanent_redirects_path='permanent-redirects.yaml', redirects_path='redirects.yaml' ) app.before_request(apply_redirects) def _tag_view(tag_slug, page_slug, template): """ View function which gets all posts for a given tag, and returns a response loading those posts with the template provided """ page = helpers.to_int(flask.request.args.get('page'), default=1) tags = api.get_tags(slugs=[tag_slug]) if not tags: flask.abort(404)
import redirects INSIGHTS_ADMIN_URL = "https://admin.insights.ubuntu.com" app = flask.Flask(__name__) app.jinja_env.filters["monthname"] = helpers.monthname app.url_map.strict_slashes = False app.url_map.converters["regex"] = helpers.RegexConverter talisker.flask.register(app) if not app.testing: talisker.requests.configure(feeds.cached_session) apply_redirects = redirects.prepare_redirects( permanent_redirects_path="permanent-redirects.yaml", redirects_path="redirects.yaml", ) app.before_request(apply_redirects) def _tag_view(tag_slug, page_slug, template): """ View function which gets all posts for a given tag, and returns a response loading those posts with the template provided """ page = helpers.to_int(flask.request.args.get("page"), default=1) tags = api.get_tags(slugs=[tag_slug]) if not tags: flask.abort(404)