好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 edelweiss92 于 2021-3-26 17:17 编辑
国行switch连wifi时要用http协议访问ctest.cdn.n.nintendoswitch.cn
返回值要求'ok', 200 , [("Content-Type", "text/plain"), ("X-Organization", "Nintendo")]
python3 实现:
[Asm] 纯文本查看 复制代码 from flask import Flask
import sys, re
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'ok', 200 , [("Content-Type", "text/plain"), ("X-Organization", "Nintendo")]
if __name__ == '__main__':
print('ctest.cdn.nintendo.cn Server')
argvlen = ( len(sys.argv))
if argvlen == 1:
print('Usage: switch_server.exe http://yourserverip:port\nExample: switch_server.exe https://10.10.10.10:8888')
print('As there is no input, the server will be running on http://192.168.6.2:80')
url = 'http://192.168.6.2:80'
else:
url = sys.argv[1]
try:
url_s = re.split('://', url)
ssl = url_s[0]
if ':' in url_s[1]:
ip_port = re.split(':', url_s[1])
server_ip = ip_port[0]
port = ip_port[1]
else:
server_ip = url_s[1]
if ssl == 'https':
port = 443
else:
port = 80
except Exception as e:
input('Invalid input')
sys.exit()
lines = []
if ssl == 'https':
app.run(ssl_context='adhoc', port=int(port),host=str(server_ip), debug=True)
else:
app.run(host=str(server_ip), port=int(port), debug=True)
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|