This commit is contained in:
mol
2023-02-20 23:02:12 +08:00
parent a2f1b6d4fd
commit 8f884cc352
22 changed files with 16 additions and 38 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
temp/*

View File

@ -59,7 +59,7 @@ class GenericGateway(object):
logger.info("Register route: %s", route.path)
def proxy_request(*args, **kwargs):
print('成功代理', route.name)
upstream_path = route.upstream_path
for p_name in route.upstream_params:
v = get_params_from_context(p_name, kwargs)
@ -79,6 +79,7 @@ class GenericGateway(object):
if request.form:
upstream_req_info['data'] = request.form
# print('upstream_req_info', upstream_req_info)
for pipe_handler in route.inbound_pipes():
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'].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)
# print(resp.headers)
status = resp.status_code
content = None
headers = resp.headers
print(route.outbound_pipes())
for pipe_handler in route.outbound_pipes():
resp, headers, status, content = pipe_handler(resp, headers, status, content, *args, **kwargs)
content = make_response(content or resp.content)
for h_name, h_value in (headers or {}).items():
# print(h_name, h_value)
content.headers[h_name] = h_value
# print('content', headers)
return content, status
# 修改函数名称Flask route注册使用func name必须唯一
proxy_request.__name__ = route.name
return proxy_request

Binary file not shown.

Binary file not shown.

Binary file not shown.

2
app.py
View File

@ -63,4 +63,4 @@ class GatewayServer():
gateway_server = GatewayServer()
app = gateway_server.app
app.run(port=5000, debug=True)
app.run(port=15000, host="192.168.124.12", debug=True)

View File

@ -8,8 +8,9 @@ class MusicHandler(OutboundHandler):
:return: (request, args, kwargs)
"""
# raise NotImplementedError
print("222")
print(status)
print('music handler started')
if status == 200:
navidromePlaylistSync.start()
headers['Transfer-Encoding'] = 'gzip'
return [response, headers, status, content]

View File

@ -25,9 +25,9 @@ def start():
sync()
if len(delPlaylistIds) > 0:
for delId in delPlaylistIds:
delPlaylist(delId, token)
# if len(delPlaylistIds) > 0:
# for delId in delPlaylistIds:
# delPlaylist(delId, token)
if __name__ == 'main':
start()

View File

@ -1,3 +0,0 @@
#EXTM3U
#EXTINF:317,浮森かや子 - お隣はだあれ
/music/浮森かや子/お隣はだあれ.mp3

View File

@ -1 +0,0 @@
#EXTM3U

View File

@ -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
)