From f34b7967d5fd4521c2745b0b11d04caef6799a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Fri, 21 Jun 2024 07:36:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96main.py=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E6=95=88=E4=BB=A3=E7=A0=81=E5=92=8C?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20-=20=E7=A7=BB=E9=99=A4=E4=BA=86`extra-hook?= =?UTF-8?q?s/=5F=5Finit=5F=5F.py`=E4=B8=AD=E7=9A=84=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=EF=BC=8C=E8=AF=A5=E6=96=87=E4=BB=B6=E7=8E=B0=E5=9C=A8=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E3=80=82=20-=20=E5=9C=A8`main.py`=E4=B8=AD=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=BA=86=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E8=AF=AD=E5=8F=A5=E5=92=8C=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=90=AF=E5=8A=A8=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E3=80=82=20-=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=86`main.spec`=E6=96=87=E4=BB=B6=EF=BC=8C=E5=9B=A0?= =?UTF-8?q?=E4=B8=BA=E5=AE=83=E6=98=AFPyInstaller=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9A=84=E4=B8=80=E9=83=A8=E5=88=86=EF=BC=8C?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E7=9A=84=E6=9B=B4=E6=94=B9=E4=BE=A7=E9=87=8D?= =?UTF-8?q?=E4=BA=8E=E6=BA=90=E4=BB=A3=E7=A0=81=E7=9A=84=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=92=8C=E4=BC=98=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/extra-hooks/__init__.py | 1 - backend/main.py | 14 ------ backend/main.spec | 83 --------------------------------- 3 files changed, 98 deletions(-) delete mode 100644 backend/extra-hooks/__init__.py delete mode 100644 backend/main.spec diff --git a/backend/extra-hooks/__init__.py b/backend/extra-hooks/__init__.py deleted file mode 100644 index ea9158f..0000000 --- a/backend/extra-hooks/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# 用于build exe 使用 \ No newline at end of file diff --git a/backend/main.py b/backend/main.py index b12587d..2408243 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,27 +1,13 @@ import multiprocessing import os import sys -import time -import threading -import webbrowser root_path = os.getcwd() sys.path.append(root_path) import uvicorn -from pathlib import Path from application.settings import LOGGING -BASE_DIR = Path(__file__).resolve().parent.parent -url = "http://127.0.0.1:8000/web/" - - -def open_browser_after_delay(url, delay): - time.sleep(delay) - webbrowser.open(url) - - if __name__ == '__main__': multiprocessing.freeze_support() - threading.Thread(target=open_browser_after_delay, args=(url, 3)).start() uvicorn.run("application.asgi:application", reload=False, host="0.0.0.0", port=8000, workers=4, log_config=LOGGING) diff --git a/backend/main.spec b/backend/main.spec deleted file mode 100644 index 5d87acb..0000000 --- a/backend/main.spec +++ /dev/null @@ -1,83 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -a = Analysis( - ['main.py'], - pathex=['./'], - binaries=[], - datas=[ - ('./static', 'static'), - ('./static/captcha/fonts', 'captcha/fonts'), - ('./templates', 'templates'), - ('./dvadmin/system/util', 'dvadmin/system/util'), - ('./plugins/__init__.py', 'plugins/__init__.py'), - ('./db.sqlite3', './'), - ], - hiddenimports=[ - "django", - "testfixtures", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "django_comment_migrate", - "rest_framework", - "django_filters", - "corsheaders", # 注册跨域app - "drf_yasg", - "captcha", - "channels", - "dvadmin.system", - "plugins.gla", - "testfixtures", - "application.asgi", - "dvadmin.utils.middleware", - "whitenoise", - "whitenoise.middleware", - "whitenoise.storage", - "dvadmin.utils.pagination", - "dvadmin.utils.exception", - "rest_framework_simplejwt.state", - ], - hookspath=['./extra-hooks'], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - noarchive=False, - optimize=0, -) -pyz = PYZ(a.pure) - -exe = EXE( - pyz, - a.scripts, - [], - exclude_binaries=True, - name='main', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - console=False, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -) -coll = COLLECT( - exe, - a.binaries, - a.datas, - strip=False, - upx=True, - upx_exclude=[], - name='main', -) -app = BUNDLE( - coll, - name='main.app', - icon=None, - bundle_identifier=None, -)