build: docker

This commit is contained in:
mol
2023-04-19 13:14:13 +08:00
parent 8f884cc352
commit a2caaddef4
7 changed files with 29 additions and 7 deletions

9
Dockerfile Normal file
View 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"]

Binary file not shown.

3
gunicorn.conf.py Normal file
View File

@ -0,0 +1,3 @@
workers = 5 # 定义同时开启的处理请求的进程数量,根据网站流量适当调整
worker_class = "gevent" # 采用gevent库支持异步处理请求提高吞吐量
bind = "0.0.0.0:80"

View File

@ -1,10 +1,12 @@
import requests
host = 'http://192.168.124.12:4533'
def getPlaylist(token):
headers = {
'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()
return resJson
@ -13,13 +15,13 @@ def downloadPlayList(palyListId, token):
'Accept': 'audio/x-mpegurl',
'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
def delPlaylist(playlistId, token):
headers = {
'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()
return resJson

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

5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
gunicorn
gevent
flask
requests
webdavclient3

View File

@ -63,4 +63,7 @@ class GatewayServer():
gateway_server = GatewayServer()
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)