diff --git a/pdm.lock b/pdm.lock index 2b54046..eeed407 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default"] strategy = ["cross_platform"] lock_version = "4.4.1" -content_hash = "sha256:3137b159cf24210912a6a3d16e6ae42511177b211996625fe6bdabebdaec230e" +content_hash = "sha256:d771311a452ca58665efe3b74af341cb202d75d83a250896c293ea9c696e5696" [[package]] name = "aiohttp" @@ -668,6 +668,16 @@ files = [ {file = "urllib3-2.0.6.tar.gz", hash = "sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564"}, ] +[[package]] +name = "waitress" +version = "3.0.0" +requires_python = ">=3.8.0" +summary = "Waitress WSGI server" +files = [ + {file = "waitress-3.0.0-py3-none-any.whl", hash = "sha256:2a06f242f4ba0cc563444ca3d1998959447477363a2d7e9b8b4d75d35cfd1669"}, + {file = "waitress-3.0.0.tar.gz", hash = "sha256:005da479b04134cdd9dd602d1ee7c49d79de0537610d653674cc6cbde222b8a1"}, +] + [[package]] name = "websockets" version = "12.0" diff --git a/pyproject.toml b/pyproject.toml index 244fa81..b88512e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ dependencies = [ "mutagen>=1.47.0", "yt-dlp>=2024.04.09", "flask[async]>=3.0.1", + "waitress>=3.0.0", ] requires-python = ">=3.10" readme = "README.md" @@ -21,3 +22,5 @@ license = {text = "MIT"} [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" + +[tool.pdm] diff --git a/requirements.txt b/requirements.txt index d7efa9b..bfec243 100644 --- a/requirements.txt +++ b/requirements.txt @@ -380,6 +380,9 @@ typing-extensions==4.9.0; python_version < "3.11" \ urllib3==2.0.6 \ --hash=sha256:7a7c7003b000adf9e7ca2a377c9688bbc54ed41b985789ed576570342a375cd2 \ --hash=sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564 +waitress==3.0.0 \ + --hash=sha256:005da479b04134cdd9dd602d1ee7c49d79de0537610d653674cc6cbde222b8a1 \ + --hash=sha256:2a06f242f4ba0cc563444ca3d1998959447477363a2d7e9b8b4d75d35cfd1669 websockets==12.0 \ --hash=sha256:00700340c6c7ab788f176d118775202aadea7602c5cc6be6ae127761c16d6b0b \ --hash=sha256:0bee75f400895aef54157b36ed6d3b308fcab62e5260703add87f44cee9c82a6 \ diff --git a/xiaomusic/httpserver.py b/xiaomusic/httpserver.py index 413bde7..8bbe983 100644 --- a/xiaomusic/httpserver.py +++ b/xiaomusic/httpserver.py @@ -5,6 +5,7 @@ import traceback import asyncio from flask import Flask, request, send_from_directory +from waitress import serve from threading import Thread from xiaomusic.config import ( @@ -17,8 +18,8 @@ from xiaomusic import ( # 隐藏 flask 启动告警 # https://gist.github.com/jerblack/735b9953ba1ab6234abb43174210d356 -cli = sys.modules['flask.cli'] -cli.show_server_banner = lambda *x: None +#from flask import cli +#cli.show_server_banner = lambda *_: None app = Flask(__name__) host = "0.0.0.0" @@ -101,10 +102,8 @@ def static_path_handler(filename): log.debug(absolute_path) return send_from_directory(absolute_path, filename) - def run_app(): - app.run(host=host, port=port) - + serve(app, host=host, port=port) def StartHTTPServer(_port, _static_path, _xiaomusic): global port, static_path, xiaomusic, log