Compare commits
No commits in common. "30b4d27c6a4ebc13090093206ee3378c563aeafc" and "dc32cc7222f81ce70fbae7e7a284f10489219753" have entirely different histories.
30b4d27c6a
...
dc32cc7222
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,4 +2,3 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
instance
|
instance
|
||||||
.env
|
.env
|
||||||
run.fcgi
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,14 @@
|
||||||
"""Package initialization for the alt text generator app."""
|
"""Package initialization for the alt text generator app."""
|
||||||
|
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
sys.path.append("/home/edward/src/2024/UniAuth") # isort:skip
|
|
||||||
|
|
||||||
from .cache import AltTextCache
|
from .cache import AltTextCache
|
||||||
from .config import load_settings
|
from .config import load_settings
|
||||||
from .immich import ImmichClient
|
from .immich import ImmichClient
|
||||||
from .mastodon import MastodonClient
|
|
||||||
from .openai_client import AltTextGenerator
|
from .openai_client import AltTextGenerator
|
||||||
|
from .mastodon import MastodonClient
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> Flask:
|
def create_app() -> Flask:
|
||||||
|
|
@ -29,16 +26,17 @@ def create_app() -> Flask:
|
||||||
|
|
||||||
secret_key = app.config.get("SECRET_KEY") or "dev-secret-key"
|
secret_key = app.config.get("SECRET_KEY") or "dev-secret-key"
|
||||||
app.config["SECRET_KEY"] = secret_key
|
app.config["SECRET_KEY"] = secret_key
|
||||||
app.config["UNIAUTH_URL"] = "https://edwardbetts.com/UniAuth"
|
|
||||||
app.config["REQUIRE_AUTH"] = True
|
|
||||||
app.config["AUTH_CALLBACK_ENDPOINT"] = "main.auth_callback"
|
|
||||||
|
|
||||||
instance_dir = Path(app.instance_path)
|
instance_dir = Path(app.instance_path)
|
||||||
instance_dir.mkdir(parents=True, exist_ok=True)
|
instance_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
db_path = app.config.get("STATION_DB")
|
db_path = app.config.get("STATION_DB")
|
||||||
if not db_path:
|
if not db_path:
|
||||||
db_path = str(instance_dir / "station_announcer.db")
|
old_db = instance_dir / "alt_text_cache.db"
|
||||||
|
new_db = instance_dir / "station_announcer.db"
|
||||||
|
if old_db.exists() and not new_db.exists():
|
||||||
|
old_db.rename(new_db)
|
||||||
|
db_path = str(new_db)
|
||||||
app.config["STATION_DB"] = db_path
|
app.config["STATION_DB"] = db_path
|
||||||
|
|
||||||
app.immich_client = ImmichClient(
|
app.immich_client = ImmichClient(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from __future__ import annotations
|
||||||
import base64
|
import base64
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import UniAuth.auth
|
|
||||||
from flask import (
|
from flask import (
|
||||||
Blueprint,
|
Blueprint,
|
||||||
Response,
|
Response,
|
||||||
|
|
@ -106,15 +105,6 @@ def _unique_asset_ids(values: list[str]) -> list[str]:
|
||||||
MAX_MEDIA_ATTACHMENTS = 4
|
MAX_MEDIA_ATTACHMENTS = 4
|
||||||
|
|
||||||
|
|
||||||
bp.before_request(UniAuth.auth.require_authentication)
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/callback")
|
|
||||||
def auth_callback():
|
|
||||||
"""Process the authentication callback."""
|
|
||||||
return UniAuth.auth.auth_callback()
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/")
|
@bp.route("/")
|
||||||
def index():
|
def index():
|
||||||
return redirect(url_for("main.compose_select"))
|
return redirect(url_for("main.compose_select"))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue