Skip to content

Commit

Permalink
Merge pull request #15 from Spiderpig02/14-create-os-independent-star…
Browse files Browse the repository at this point in the history
…tup-script-for-django-backend-and-react-frontend

14 create os independent startup script for django backend and react frontend
  • Loading branch information
SverreNystad authored Jan 2, 2024
2 parents 6de5e45 + 0d2dd02 commit 684fa0a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions start_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""A setup script that starts the Django backend and React frontend in separate processes."""

import os
import subprocess
import sys
import logging

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger("start_project.py")


def start_django() -> None:
logger.info("Starting Django backend...")
try:
os.chdir('backend')
subprocess.Popen([sys.executable, 'manage.py', 'runserver'])
except FileNotFoundError:
logger.error("Script manage.py not found. Are you sure you are in the root directory?")
sys.exit(1)


def start_react() -> None:
logger.info("Starting React frontend...")
try:
os.chdir('frontend')
subprocess.Popen('npm install', shell=True)
subprocess.Popen('npm run dev', shell=True)

except FileNotFoundError:
logger.error("Manifest package.json not found. Are you sure you are in the root directory?")
sys.exit(1)

if __name__ == '__main__':
start_django()
start_react()

0 comments on commit 684fa0a

Please sign in to comment.