Spaces:
Running
Running
cutycat2000x
commited on
Commit
•
cfea4a6
1
Parent(s):
20f4cd1
Update app.py
Browse files
app.py
CHANGED
@@ -10,11 +10,26 @@ CHAT_UI_HOST = 'cutycat2000x-instantchat.static.hf.space'
|
|
10 |
@app.route("/<path:path>", methods=['GET', 'POST'])
|
11 |
def handle_request(path=""):
|
12 |
chat_ui_url = f'https://{DISCORD_ROCKS_HOST}/{path}'
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
app.run(host="0.0.0.0", port=7860)
|
|
|
10 |
@app.route("/<path:path>", methods=['GET', 'POST'])
|
11 |
def handle_request(path=""):
|
12 |
chat_ui_url = f'https://{DISCORD_ROCKS_HOST}/{path}'
|
13 |
+
|
14 |
+
# Pass method, data, and params from the original request
|
15 |
+
method = request.method
|
16 |
+
data = request.data
|
17 |
+
params = request.args
|
18 |
+
|
19 |
+
# Make a request to the new URL with the provided method, data, and params
|
20 |
+
if method == 'GET':
|
21 |
+
response = requests.get(chat_ui_url, params=params)
|
22 |
+
elif method == 'POST':
|
23 |
+
response = requests.post(chat_ui_url, params=params, data=data)
|
24 |
+
else:
|
25 |
+
return Response(status=405, response="Method Not Allowed")
|
26 |
+
|
27 |
+
# Create a response with the content received from the new URL
|
28 |
+
proxied_response = Response(response.content)
|
29 |
+
proxied_response.status_code = response.status_code
|
30 |
+
proxied_response.headers["Content-Type"] = "text/html"
|
31 |
+
|
32 |
+
return proxied_response
|
33 |
|
34 |
if __name__ == "__main__":
|
35 |
app.run(host="0.0.0.0", port=7860)
|