2021-07-07 15:07:20 +00:00
|
|
|
"""Main Flask application."""
|
|
|
|
from flask import Flask
|
|
|
|
from flask_caching import Cache
|
2022-01-01 07:28:11 +00:00
|
|
|
import flask_gae_static
|
2021-07-18 04:22:13 +00:00
|
|
|
from oauth_dropins.webutil import (
|
|
|
|
appengine_info,
|
|
|
|
appengine_config,
|
|
|
|
flask_util,
|
|
|
|
util,
|
|
|
|
)
|
2021-07-11 20:39:19 +00:00
|
|
|
|
2021-07-12 20:49:48 +00:00
|
|
|
import common
|
|
|
|
|
2019-12-26 06:20:57 +00:00
|
|
|
|
2022-01-01 07:28:11 +00:00
|
|
|
app = Flask(__name__)
|
2021-07-07 15:07:20 +00:00
|
|
|
app.template_folder = './templates'
|
|
|
|
app.config.from_mapping(
|
|
|
|
ENV='development' if appengine_info.DEBUG else 'PRODUCTION',
|
|
|
|
CACHE_TYPE='SimpleCache',
|
|
|
|
SECRET_KEY=util.read('flask_secret_key'),
|
2021-07-08 04:02:13 +00:00
|
|
|
JSONIFY_PRETTYPRINT_REGULAR=True,
|
2021-07-07 15:07:20 +00:00
|
|
|
)
|
2021-07-18 04:22:13 +00:00
|
|
|
app.url_map.converters['regex'] = flask_util.RegexConverter
|
2021-07-28 04:58:05 +00:00
|
|
|
app.after_request(flask_util.default_modern_headers)
|
|
|
|
app.register_error_handler(Exception, flask_util.handle_exception)
|
2022-02-12 06:38:40 +00:00
|
|
|
if appengine_info.DEBUG:
|
|
|
|
flask_gae_static.init_app(app)
|
2021-07-28 04:58:05 +00:00
|
|
|
|
2021-08-06 17:28:56 +00:00
|
|
|
# don't redirect API requests with blank path elements
|
|
|
|
app.url_map.redirect_defaults = True
|
|
|
|
|
2021-08-16 18:47:31 +00:00
|
|
|
app.wsgi_app = flask_util.ndb_context_middleware(
|
2021-07-07 15:07:20 +00:00
|
|
|
app.wsgi_app, client=appengine_config.ndb_client)
|
2019-12-26 06:20:57 +00:00
|
|
|
|
2021-07-07 15:07:20 +00:00
|
|
|
cache = Cache(app)
|
2019-12-26 06:20:57 +00:00
|
|
|
|
2022-03-17 04:11:09 +00:00
|
|
|
util.set_user_agent('Bridgy Fed (https://fed.brid.gy/)')
|
|
|
|
|
2021-07-12 00:55:59 +00:00
|
|
|
|
2021-07-07 15:07:20 +00:00
|
|
|
import activitypub, add_webmention, logs, redirect, render, salmon, superfeedr, webfinger, webmention
|