cutycat2000x commited on
Commit
cfea4a6
1 Parent(s): 20f4cd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
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
- response = Response()
14
- response.status_code = 200
15
- response.content_type = "text/html"
16
- response.data = requests.get(chat_ui_url).content
17
- return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)