-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Spiderpig02/14-create-os-independent-star…
…tup-script-for-django-backend-and-react-frontend 14 create os independent startup script for django backend and react frontend
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |