更新
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
temp/*
|
12
Gateway.py
12
Gateway.py
@ -59,7 +59,7 @@ class GenericGateway(object):
|
|||||||
logger.info("Register route: %s", route.path)
|
logger.info("Register route: %s", route.path)
|
||||||
|
|
||||||
def proxy_request(*args, **kwargs):
|
def proxy_request(*args, **kwargs):
|
||||||
|
print('成功代理', route.name)
|
||||||
upstream_path = route.upstream_path
|
upstream_path = route.upstream_path
|
||||||
for p_name in route.upstream_params:
|
for p_name in route.upstream_params:
|
||||||
v = get_params_from_context(p_name, kwargs)
|
v = get_params_from_context(p_name, kwargs)
|
||||||
@ -79,6 +79,7 @@ class GenericGateway(object):
|
|||||||
if request.form:
|
if request.form:
|
||||||
upstream_req_info['data'] = request.form
|
upstream_req_info['data'] = request.form
|
||||||
|
|
||||||
|
# print('upstream_req_info', upstream_req_info)
|
||||||
for pipe_handler in route.inbound_pipes():
|
for pipe_handler in route.inbound_pipes():
|
||||||
upstream_req_info, args, kwargs = pipe_handler(upstream_req_info, *args, **kwargs)
|
upstream_req_info, args, kwargs = pipe_handler(upstream_req_info, *args, **kwargs)
|
||||||
|
|
||||||
@ -88,20 +89,23 @@ class GenericGateway(object):
|
|||||||
upstream_req_info['headers'] = {k: v for k, v in upstream_req_info['headers'].items()}
|
upstream_req_info['headers'] = {k: v for k, v in upstream_req_info['headers'].items()}
|
||||||
upstream_req_info['headers'].pop('Content-Type', None)
|
upstream_req_info['headers'].pop('Content-Type', None)
|
||||||
upstream_req_info['headers'].pop('content-type', None)
|
upstream_req_info['headers'].pop('content-type', None)
|
||||||
|
|
||||||
|
# print('upstream_req_info', upstream_req_info)
|
||||||
resp = requests.request(**upstream_req_info)
|
resp = requests.request(**upstream_req_info)
|
||||||
|
# print(resp.headers)
|
||||||
status = resp.status_code
|
status = resp.status_code
|
||||||
content = None
|
content = None
|
||||||
headers = resp.headers
|
headers = resp.headers
|
||||||
|
print(route.outbound_pipes())
|
||||||
for pipe_handler in route.outbound_pipes():
|
for pipe_handler in route.outbound_pipes():
|
||||||
resp, headers, status, content = pipe_handler(resp, headers, status, content, *args, **kwargs)
|
resp, headers, status, content = pipe_handler(resp, headers, status, content, *args, **kwargs)
|
||||||
|
|
||||||
content = make_response(content or resp.content)
|
content = make_response(content or resp.content)
|
||||||
for h_name, h_value in (headers or {}).items():
|
for h_name, h_value in (headers or {}).items():
|
||||||
|
# print(h_name, h_value)
|
||||||
content.headers[h_name] = h_value
|
content.headers[h_name] = h_value
|
||||||
|
# print('content', headers)
|
||||||
return content, status
|
return content, status
|
||||||
|
|
||||||
# 修改函数名称:Flask route注册使用func name必须唯一
|
# 修改函数名称:Flask route注册使用func name必须唯一
|
||||||
proxy_request.__name__ = route.name
|
proxy_request.__name__ = route.name
|
||||||
return proxy_request
|
return proxy_request
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
app.py
2
app.py
@ -63,4 +63,4 @@ class GatewayServer():
|
|||||||
|
|
||||||
gateway_server = GatewayServer()
|
gateway_server = GatewayServer()
|
||||||
app = gateway_server.app
|
app = gateway_server.app
|
||||||
app.run(port=5000, debug=True)
|
app.run(port=15000, host="192.168.124.12", debug=True)
|
@ -8,8 +8,9 @@ class MusicHandler(OutboundHandler):
|
|||||||
:return: (request, args, kwargs)
|
:return: (request, args, kwargs)
|
||||||
"""
|
"""
|
||||||
# raise NotImplementedError
|
# raise NotImplementedError
|
||||||
print("222")
|
print('music handler started')
|
||||||
print(status)
|
|
||||||
if status == 200:
|
if status == 200:
|
||||||
navidromePlaylistSync.start()
|
navidromePlaylistSync.start()
|
||||||
|
|
||||||
|
headers['Transfer-Encoding'] = 'gzip'
|
||||||
return [response, headers, status, content]
|
return [response, headers, status, content]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -25,9 +25,9 @@ def start():
|
|||||||
|
|
||||||
sync()
|
sync()
|
||||||
|
|
||||||
if len(delPlaylistIds) > 0:
|
# if len(delPlaylistIds) > 0:
|
||||||
for delId in delPlaylistIds:
|
# for delId in delPlaylistIds:
|
||||||
delPlaylist(delId, token)
|
# delPlaylist(delId, token)
|
||||||
|
|
||||||
if __name__ == 'main':
|
if __name__ == 'main':
|
||||||
start()
|
start()
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
#EXTM3U
|
|
||||||
#EXTINF:317,浮森かや子 - お隣はだあれ
|
|
||||||
/music/浮森かや子/お隣はだあれ.mp3
|
|
@ -1 +0,0 @@
|
|||||||
#EXTM3U
|
|
Binary file not shown.
Binary file not shown.
24
test2.py
24
test2.py
@ -1,24 +0,0 @@
|
|||||||
from flask import Flask
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route("/api/tracks")
|
|
||||||
def hello_tracks():
|
|
||||||
return "<p>Hello, tracks!</p>"
|
|
||||||
|
|
||||||
@app.route("/api/playlist/<playlist_id>/tracks")
|
|
||||||
def hello_playlist():
|
|
||||||
return "<p>Hello, playlist!</p>"
|
|
||||||
|
|
||||||
app.run(
|
|
||||||
host = '127.0.0.1',
|
|
||||||
port = 7777,
|
|
||||||
debug = True
|
|
||||||
)
|
|
||||||
|
|
||||||
if __name__== '__main__':
|
|
||||||
app.run(
|
|
||||||
host = '127.0.0.1',
|
|
||||||
port = 7777,
|
|
||||||
debug = True
|
|
||||||
)
|
|
Reference in New Issue
Block a user