try: ditch waitress

This commit is contained in:
cwilvx
2025-02-07 17:10:27 +03:00
parent 7082f30209
commit beec5bc7d3
6 changed files with 1666 additions and 69 deletions
+1
View File
@@ -67,6 +67,7 @@ def create_api():
app = OpenAPI(__name__, info=api_info, doc_prefix="/docs") app = OpenAPI(__name__, info=api_info, doc_prefix="/docs")
# JWT CONFIGS # JWT CONFIGS
app.config["JWT_VERIFY_SUB"] = False
app.config["JWT_SECRET_KEY"] = UserConfig().serverId app.config["JWT_SECRET_KEY"] = UserConfig().serverId
app.config["JWT_TOKEN_LOCATION"] = ["cookies", "headers"] app.config["JWT_TOKEN_LOCATION"] = ["cookies", "headers"]
app.config["JWT_COOKIE_CSRF_PROTECT"] = False app.config["JWT_COOKIE_CSRF_PROTECT"] = False
+18 -2
View File
@@ -3,11 +3,12 @@ Contains all the track routes.
""" """
import os import os
from pathlib import Path
import tempfile import tempfile
import time import time
from typing import Literal from typing import Literal
from flask import send_file, request, Response from flask import send_file, request, Response, send_from_directory
from flask_openapi3 import APIBlueprint, Tag from flask_openapi3 import APIBlueprint, Tag
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from app.api.apischemas import TrackHashSchema from app.api.apischemas import TrackHashSchema
@@ -84,7 +85,22 @@ def send_track_file_legacy(path: TrackHashSchema, query: SendTrackFileQuery):
if track is not None: if track is not None:
audio_type = guess_mime_type(filepath) audio_type = guess_mime_type(filepath)
return send_file(filepath, mimetype=audio_type, conditional=True) # return send_file(
# filepath,
# mimetype=audio_type,
# conditional=True,
# # environ=request.environ,
# as_attachment=True,
# max_age=None,
# )
return send_from_directory(
Path(filepath).parent,
Path(filepath).name,
mimetype=audio_type,
conditional=True,
as_attachment=True,
)
# return ""
return msg, 404 return msg, 404
+9 -2
View File
@@ -1,8 +1,15 @@
from locust import HttpUser, task from locust import HttpUser, task
class HelloWorldUser(HttpUser): class HelloWorldUser(HttpUser):
host = "http://localhost:1980" host = "http://localhost:1980"
# @task
# def get_all_artists(self):
# self.client.get(
# "/getall/artists?start=0&limit=50&sortby=created_date&reverse=1"
# )
@task @task
def hello_world(self): def get_album_info(self):
self.client.get("/getall/artists?start=0&limit=50&sortby=created_date&reverse=1") self.client.get("/artist/9e6781427eab4934")
+11 -10
View File
@@ -229,17 +229,18 @@ if __name__ == "__main__":
load_into_mem() load_into_mem()
run_swingmusic() run_swingmusic()
TrackStore.export() # TrackStore.export()
ArtistStore.export() # ArtistStore.export()
host = FLASKVARS.get_flask_host() host = FLASKVARS.get_flask_host()
port = FLASKVARS.get_flask_port() port = FLASKVARS.get_flask_port()
waitress.serve( # waitress.serve(
app, # app,
host=host, # host=host,
port=port, # port=port,
threads=100, # threads=100,
ipv6=True, # ipv6=True,
ipv4=True, # ipv4=True,
) # )
app.run(host=host, port=port, debug=False)
+39 -55
View File
@@ -1,57 +1,41 @@
[tool.poetry] [project]
name = "Swing music player" name = "swing_music"
version = "0.1.0" version = "2.0.0"
description = "" description = "Add your description here"
authors = ["geoffrey45 <geoffreymungai45@gmail.com>"] readme = "README.md"
package-mode = false requires-python = ">=3.11"
[tool.poetry.dependencies] dependencies = [
python = ">=3.10,<3.12" "pillow>=11.1.0",
Flask = "^2.0.2" "Flask>=3.1.0",
Flask-Cors = "^3.0.10" "Flask-Cors>=3.0.10",
requests = "^2.27.1" "requests>=2.27.1",
Pillow = "^9.0.1" "colorgram.py>=1.2.0",
"colorgram.py" = "^1.2.0" "tqdm>=4.65.0",
tqdm = "^4.65.0" "rapidfuzz>=2.13.7",
rapidfuzz = "^2.13.7" "tinytag>=2.0.0",
tinytag = ">=2.0.0" "Unidecode>=1.3.6",
Unidecode = "^1.3.6" "psutil>=5.9.4",
psutil = "^5.9.4" "show-in-file-manager>=1.1.4",
show-in-file-manager = "^1.1.4" "flask-compress>=1.13",
flask-compress = "^1.13" "tabulate>=0.9.0",
tabulate = "^0.9.0" "setproctitle>=1.3.2",
setproctitle = "^1.3.2" "locust>=2.20.1",
locust = "^2.20.1" "waitress>=2.1.2",
waitress = "^2.1.2" "watchdog>=4.0.0",
watchdog = "^4.0.0" "pendulum>=3.0.0",
pendulum = "^3.0.0" "flask-jwt-extended>=4.6.0",
flask-openapi3 = "^3.0.2" "sqlalchemy>=2.0.31",
flask-jwt-extended = "^4.6.0" "memory-profiler>=0.61.0",
sqlalchemy = "^2.0.31" "sortedcontainers>=2.4.0",
memory-profiler = "^0.61.0" "xxhash>=3.4.1",
sortedcontainers = "^2.4.0" "ffmpeg-python>=0.2.0",
xxhash = "^3.4.1" "schedule>=1.2.2",
ffmpeg-python = "^0.2.0" "flask-openapi3>=4.0.3",
schedule = "^1.2.2" "pillow>=11.1.0",
]
[tool.poetry.dev-dependencies] [dependency-groups]
pylint = "^2.15.5" dev = [
pytest = "^7.1.3" "pyinstaller>=6.11.1",
hypothesis = "^6.56.3" ]
[tool.poetry.dev-dependencies.black]
version = "^22.6.0"
allow-prereleases = true
[tool.poetry.group.dev.dependencies]
pyinstaller = "^5.9.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[pytest]
console_output_style = "classic"
testpaths = "tests"
Generated
+1588
View File
File diff suppressed because it is too large Load Diff