#!/usr/bin/env python from plugin import Plugin, load_plugins_for_config from typing import Tuple from flask import Flask, request from pronoun_update import PronounUpdate import asyncio app = Flask(__name__) plugins = load_plugins_for_config(app.config.get("PLUGINS", [{"name": "log"}])) async def trigger_update_pronouns(pronouns: str) -> None: update = PronounUpdate(pronouns) await asyncio.gather(*[plugin.update_bio(update) for plugin in plugins]) @app.route("/update_pronouns", methods=["POST"]) async 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 await trigger_update_pronouns(pronouns) return pronouns, 200 if __name__ == "__main__": import logging logging.getLogger().setLevel("INFO") app.run(host="0.0.0.0", port=8080)