Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14 create os independent startup script for django backend and react frontend #15

Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 run setup', shell=True)
Spiderpig02 marked this conversation as resolved.
Show resolved Hide resolved
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()
Loading