edwagbb commited on
Commit
74a6fba
·
1 Parent(s): 76651d1

Delete proxy.py

Browse files
Files changed (1) hide show
  1. proxy.py +0 -52
proxy.py DELETED
@@ -1,52 +0,0 @@
1
- from flask import Flask, request, Response
2
- import cloudscraper
3
- scraper = cloudscraper.create_scraper(interpreter='nodejs')
4
-
5
- app = Flask(__name__)
6
-
7
- @app.route('/proxy/<scheme>:/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])
8
- def proxy(scheme, url):
9
- req_method = request.method
10
- req_headers = {key: value for key, value in request.headers if key != 'Host'}
11
- req_data = request.get_data()
12
-
13
- resp = scraper.request(method=req_method,
14
- url=f'{scheme}://{url}',
15
- headers=req_headers,
16
- data=req_data,
17
- stream=True)
18
-
19
- excluded_headers = [] #['content-encoding', 'content-length', 'transfer-encoding', 'connection']
20
- headers = [(name, value) for (name, value) in resp.raw.headers.items()
21
- if name.lower() not in excluded_headers]
22
-
23
- def generate():
24
- for chunk in resp.iter_content(chunk_size=1):
25
- yield chunk
26
-
27
- return Response(generate(), status=resp.status_code, headers=headers)
28
-
29
- @app.route('/', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])
30
- @app.route('/<path:url>', methods=['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])
31
- def cf(url=""):
32
- req_method = request.method
33
- req_headers = {key: value for key, value in request.headers if key != 'Host'}
34
- req_data = request.get_data()
35
-
36
- resp = scraper.request(method=req_method,
37
- url=f'https://chat-shared3.zhile.io/{url}',
38
- headers=req_headers,
39
- data=req_data,
40
- stream=True)
41
-
42
- excluded_headers = [] #['content-encoding', 'content-length', 'transfer-encoding', 'connection']
43
- headers = [(name, value) for (name, value) in resp.raw.headers.items()
44
- if name.lower() not in excluded_headers]
45
-
46
- def generate():
47
- for chunk in resp.iter_content(chunk_size=1):
48
- yield chunk
49
-
50
- return Response(generate(), status=resp.status_code, headers=headers)
51
- if __name__ == '__main__':
52
- app.run(host='0.0.0.0', port=7860)