From fe3191d4a2272805134a9c4c9998e09b8bdedd8f Mon Sep 17 00:00:00 2001 From: Nell Date: Sun, 13 Apr 2025 11:59:50 +0200 Subject: [PATCH] init --- app/app/asgi.py | 7 +- app/app/settings.py | 2 - app/app/utils.py | 4 +- app/dev_run.sh | 7 +- app/frontend/src/components/torrent/App.vue | 77 +++++++--- app/frontend/src/components/torrent/DM.vue | 75 +++++++++ .../src/components/torrent/DMDetails.vue | 123 +++++++++++++++ .../src/components/torrent/FileItem.vue | 13 +- .../src/components/torrent/FileList.vue | 1 + .../src/components/torrent/TorrentItem.vue | 34 +++-- app/frontend/src/plugins/params.js | 13 ++ app/frontend/src/plugins/qtwebchannel.js | 76 ++++++++++ app/frontend/src/plugins/vue_loader.js | 3 +- app/frontend/src/plugins/ws.js | 143 ++++++++++-------- app/frontend/src/styles/main.css | 26 ++++ app/requirements.txt | 7 +- app/torrent/models.py | 18 ++- app/torrent/templates/torrent/home.html | 10 ++ app/torrent/urls.py | 3 +- app/torrent/views.py | 40 ++++- docker-compose.yml | 2 +- 21 files changed, 567 insertions(+), 117 deletions(-) create mode 100644 app/frontend/src/components/torrent/DM.vue create mode 100644 app/frontend/src/components/torrent/DMDetails.vue create mode 100644 app/frontend/src/plugins/params.js create mode 100644 app/frontend/src/plugins/qtwebchannel.js create mode 100644 app/frontend/src/styles/main.css diff --git a/app/app/asgi.py b/app/app/asgi.py index 6ae490c..54792e0 100644 --- a/app/app/asgi.py +++ b/app/app/asgi.py @@ -1,6 +1,8 @@ import os - +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') from django.core.asgi import get_asgi_application +django_asgi_app = get_asgi_application() + from channels.auth import AuthMiddlewareStack from channels.sessions import SessionMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter @@ -8,8 +10,7 @@ from channels.routing import ProtocolTypeRouter, URLRouter from app.channels_middleware import JwtOrSessionAuthMiddleware -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings') -django_asgi_app = get_asgi_application() + from .ws_urls import websocket_urlpatterns diff --git a/app/app/settings.py b/app/app/settings.py index 49ef1ab..188fbc1 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -59,8 +59,6 @@ INSTALLED_APPS = [ 'api', 'torrent', ] -if DEBUG: - INSTALLED_APPS = ["daphne"] + INSTALLED_APPS MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', diff --git a/app/app/utils.py b/app/app/utils.py index 8b07ae7..075bf1c 100644 --- a/app/app/utils.py +++ b/app/app/utils.py @@ -3,7 +3,7 @@ from django.http import StreamingHttpResponse import zlib import datetime import os -import aiofiles +import anyio from stat import S_IFREG from stream_zip import ZIP_64, stream_zip, async_stream_zip from channels.layers import get_channel_layer @@ -61,7 +61,7 @@ class StreamingZipFileResponse(StreamingHttpResponse): async def contents(path): try: - async with aiofiles.open(path, "rb") as f: + async with await anyio.open_file(path, "rb") as f: while chunk := await f.read(64 * 1024): yield chunk except RuntimeError as e: diff --git a/app/dev_run.sh b/app/dev_run.sh index 3058129..a8e76f2 100644 --- a/app/dev_run.sh +++ b/app/dev_run.sh @@ -1,5 +1,10 @@ +#!/bin/bash + +CORES=$(nproc) +WORKERS=$((2 * CORES + 1)) + cd /app/frontend && yarn dev & -cd /app && python manage.py runserver 0.0.0.0:8000 & +cd /app && uvicorn app.asgi:application --workers $WORKERS --host 0.0.0.0 --port 8000 --lifespan off --loop uvloop --ws websockets --reload & wait -n diff --git a/app/frontend/src/components/torrent/App.vue b/app/frontend/src/components/torrent/App.vue index 6d2efca..8151c3c 100644 --- a/app/frontend/src/components/torrent/App.vue +++ b/app/frontend/src/components/torrent/App.vue @@ -11,24 +11,26 @@ - + + + {{dm_status}} + - - - - + + Oxpanel - - - - - + + + + + +