From 43fcb7f4250f6c58d47bf84301592e0b1103c516 Mon Sep 17 00:00:00 2001 From: Muhammed Aldulaimi Date: Sat, 29 Jul 2023 07:37:26 +0300 Subject: [PATCH] Add remote URL --- .env.example | 1 + main.py | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 .env.example 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():