#!/usr/bin/env python if __name__ == "__main__": import logging logging.getLogger().setLevel("INFO") from plugin import Plugin, load_plugins_for_config from typing import Tuple from flask import Flask, request from pronoun_update import PronounUpdate app = Flask(__name__) app.config.from_envvar("PRONOUNOMATIC_SETTINGS") plugins = load_plugins_for_config(app.config.get("PLUGINS", [{"name": "log"}])) def trigger_update_pronouns(pronouns: str) -> None: update = PronounUpdate(pronouns) [plugin.update_bio(update) for plugin in plugins] @app.route("/update_pronouns", methods=["POST"]) def update_pronouns() -> Tuple[str, int]: pronouns = request.values.get("pronouns") if not pronouns: return "Please specify a pronouns parameter as a part of your request", 422 trigger_update_pronouns(pronouns) return pronouns, 200 if __name__ == "__main__": app.run(host="0.0.0.0", port=8080)