Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
from flask import Flask, request, Response
|
| 3 |
import requests
|
| 4 |
|
|
@@ -6,6 +5,8 @@ app = Flask(__name__)
|
|
| 6 |
|
| 7 |
# 定义一个代理函数,用于向目标服务器发送请求
|
| 8 |
def proxy(url, method, headers, data):
|
|
|
|
|
|
|
| 9 |
# 设置Origin头部为https://www.bing.com
|
| 10 |
headers['Origin'] = 'https://copilot.microsoft.com'
|
| 11 |
# 根据请求方法发送相应的请求
|
|
@@ -23,7 +24,7 @@ def proxy(url, method, headers, data):
|
|
| 23 |
@app.route('/')
|
| 24 |
def index():
|
| 25 |
# 返回一个简单的消息
|
| 26 |
-
return '
|
| 27 |
|
| 28 |
# 定义一个路由,用于处理其他路径的请求
|
| 29 |
@app.route('/<path:path>')
|
|
@@ -37,6 +38,6 @@ def other(path):
|
|
| 37 |
# 调用代理函数,返回响应
|
| 38 |
return proxy(url, method, headers, data)
|
| 39 |
|
| 40 |
-
# 运行Flask应用,监听
|
| 41 |
if __name__ == '__main__':
|
| 42 |
app.run(port=10000, debug=True)
|
|
|
|
|
|
|
| 1 |
from flask import Flask, request, Response
|
| 2 |
import requests
|
| 3 |
|
|
|
|
| 5 |
|
| 6 |
# 定义一个代理函数,用于向目标服务器发送请求
|
| 7 |
def proxy(url, method, headers, data):
|
| 8 |
+
# 将不可变的 headers 对象转换为可变的字典
|
| 9 |
+
headers = dict(headers)
|
| 10 |
# 设置Origin头部为https://www.bing.com
|
| 11 |
headers['Origin'] = 'https://copilot.microsoft.com'
|
| 12 |
# 根据请求方法发送相应的请求
|
|
|
|
| 24 |
@app.route('/')
|
| 25 |
def index():
|
| 26 |
# 返回一个简单的消息
|
| 27 |
+
return 'WellCome! Site is working ......'
|
| 28 |
|
| 29 |
# 定义一个路由,用于处理其他路径的请求
|
| 30 |
@app.route('/<path:path>')
|
|
|
|
| 38 |
# 调用代理函数,返回响应
|
| 39 |
return proxy(url, method, headers, data)
|
| 40 |
|
| 41 |
+
# 运行Flask应用,监听10000端口
|
| 42 |
if __name__ == '__main__':
|
| 43 |
app.run(port=10000, debug=True)
|