diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..41a50a38 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +REMOTE_URL="https://your-website.com" \ No newline at end of file diff --git a/main.py b/main.py index a408731a..1dbfc19a 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,12 @@ import json +import os import quart import quart_cors from quart import request +REMOTE_URL = os.getenv('REMOTE_URL', None) + app = quart_cors.cors(quart.Quart(__name__), allow_origin="https://chat.openai.com") # Keep track of todo's. Does not persist if Python session is restarted. @@ -40,6 +43,8 @@ async def plugin_manifest(): host = request.headers['Host'] with open("./.well-known/ai-plugin.json") as f: text = f.read() + if REMOTE_URL: + text = text.replace("http://localhost:5003", REMOTE_URL) return quart.Response(text, mimetype="text/json") @app.get("/openapi.yaml") @@ -47,6 +52,8 @@ async def openapi_spec(): host = request.headers['Host'] with open("openapi.yaml") as f: text = f.read() + if REMOTE_URL: + text = text.replace("http://localhost:5003", REMOTE_URL) return quart.Response(text, mimetype="text/yaml") def main():