From 261b2146c7015be87f74d9ad744d13e9cb4d5745 Mon Sep 17 00:00:00 2001 From: JusticeV452 <55002917+JusticeV452@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:50:26 -0400 Subject: [PATCH] Create launch_site.py --- .../app/management/commands/launch_site.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 backend/app/management/commands/launch_site.py diff --git a/backend/app/management/commands/launch_site.py b/backend/app/management/commands/launch_site.py new file mode 100644 index 00000000..80a9b82c --- /dev/null +++ b/backend/app/management/commands/launch_site.py @@ -0,0 +1,24 @@ +""" +Django management command launch_site +""" + +import platform +import subprocess + +from django.core.management.base import BaseCommand +from django.core.management import call_command + + +class Command(BaseCommand): + """ + Custom django-admin command to launch the local website + """ + + help = "Custom django-admin command to launch the local website" + + def handle(self, *args, **options): + on_windows = platform.system() == "Windows" + frontend_cmd = [f"npm{'.cmd' if on_windows else ''}", "run", "start"] + with subprocess.Popen(frontend_cmd) as frontend: + call_command("runserver") + frontend.kill()