build: docker
This commit is contained in:
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM python:3.6
|
||||||
|
WORKDIR /Project/Middle-server
|
||||||
|
|
||||||
|
COPY requirements.txt ./
|
||||||
|
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["gunicorn", "start:app", "-c", "./gunicorn.conf.py"]
|
BIN
__pycache__/gunicorn.conf.cpython-310.pyc
Normal file
BIN
__pycache__/gunicorn.conf.cpython-310.pyc
Normal file
Binary file not shown.
3
gunicorn.conf.py
Normal file
3
gunicorn.conf.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
workers = 5 # 定义同时开启的处理请求的进程数量,根据网站流量适当调整
|
||||||
|
worker_class = "gevent" # 采用gevent库,支持异步处理请求,提高吞吐量
|
||||||
|
bind = "0.0.0.0:80"
|
@ -1,10 +1,12 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
host = 'http://192.168.124.12:4533'
|
||||||
|
|
||||||
def getPlaylist(token):
|
def getPlaylist(token):
|
||||||
headers = {
|
headers = {
|
||||||
'x-nd-authorization': f'Bearer {token}'
|
'x-nd-authorization': f'Bearer {token}'
|
||||||
}
|
}
|
||||||
res = requests.get('https://music.hiiragi.club:8081/api/playlist?_end=50&_order=ASC&_sort=id&_start=0', headers = headers)
|
res = requests.get(f'{host}/api/playlist?_end=50&_order=ASC&_sort=id&_start=0', headers = headers)
|
||||||
resJson = res.json()
|
resJson = res.json()
|
||||||
return resJson
|
return resJson
|
||||||
|
|
||||||
@ -13,13 +15,13 @@ def downloadPlayList(palyListId, token):
|
|||||||
'Accept': 'audio/x-mpegurl',
|
'Accept': 'audio/x-mpegurl',
|
||||||
'x-nd-authorization': f'Bearer {token}'
|
'x-nd-authorization': f'Bearer {token}'
|
||||||
}
|
}
|
||||||
res = requests.get(f'https://music.hiiragi.club:8081/api/playlist/{palyListId}/tracks', headers = headers)
|
res = requests.get(f'{host}/api/playlist/{palyListId}/tracks', headers = headers)
|
||||||
return res.content
|
return res.content
|
||||||
|
|
||||||
def delPlaylist(playlistId, token):
|
def delPlaylist(playlistId, token):
|
||||||
headers = {
|
headers = {
|
||||||
'x-nd-authorization': f'Bearer {token}'
|
'x-nd-authorization': f'Bearer {token}'
|
||||||
}
|
}
|
||||||
res = requests.delete(f'https://music.hiiragi.club:8081/api/playlist/{playlistId}', headers = headers)
|
res = requests.delete(f'{host}/api/playlist/{playlistId}', headers = headers)
|
||||||
resJson = res.json()
|
resJson = res.json()
|
||||||
return resJson
|
return resJson
|
@ -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()
|
||||||
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
gunicorn
|
||||||
|
gevent
|
||||||
|
flask
|
||||||
|
requests
|
||||||
|
webdavclient3
|
@ -63,4 +63,7 @@ class GatewayServer():
|
|||||||
|
|
||||||
gateway_server = GatewayServer()
|
gateway_server = GatewayServer()
|
||||||
app = gateway_server.app
|
app = gateway_server.app
|
||||||
app.run(port=15000, host="192.168.124.12", debug=True)
|
# app.run(port=15000, host="192.168.124.12", debug=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True)
|
Reference in New Issue
Block a user