2021-07-07 15:07:20 +00:00
|
|
|
"""Main Flask application."""
|
2022-11-22 02:43:50 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
2021-07-07 15:07:20 +00:00
|
|
|
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-08-09 15:16:02 +00:00
|
|
|
app = Flask(__name__, static_folder=None)
|
2021-07-07 15:07:20 +00:00
|
|
|
app.template_folder = './templates'
|
2022-08-09 15:22:50 +00:00
|
|
|
app.json.compact = False
|
2022-11-22 02:43:50 +00:00
|
|
|
app.config.from_pyfile(Path(__file__).parent / 'config.py')
|
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-11-12 16:25:36 +00:00
|
|
|
if appengine_info.LOCAL:
|
2022-02-12 06:38:40 +00:00
|
|
|
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
|
|
|
|
2023-01-05 03:22:11 +00:00
|
|
|
import activitypub, add_webmention, follow, pages, redirect, render, superfeedr, webfinger, webmention
|