| from flask import Flask, request, Response |
| import requests |
|
|
| app = Flask(__name__) |
|
|
| |
| def proxy(url, method, headers, data): |
| |
| headers = dict(headers) |
| |
| headers['Origin'] = 'https://copilot.microsoft.com' |
| |
| if method == 'GET': |
| r = requests.get(url, headers=headers, stream=True) |
| elif method == 'POST': |
| r = requests.post(url, headers=headers, data=data, stream=True) |
| else: |
| |
| return Response(status=200) |
| |
| return Response(r.content, status=r.status_code, headers=r.headers.items()) |
|
|
| |
| @app.route('/') |
| def index(): |
| |
| return 'WellCome! Site is working ......' |
|
|
| |
| @app.route('/<path:path>') |
| def other(path): |
| |
| url = request.url.replace(request.host, 'copilot.microsoft.com') |
| |
| method = request.method |
| headers = request.headers |
| data = request.data |
| |
| return proxy(url, method, headers, data) |
|
|
| |
| if __name__ == '__main__': |
| app.run(port=10000, debug=True) |
|
|