Skip to content

Commit

Permalink
feat: add helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlo411 committed Aug 16, 2023
1 parent 04a8f0e commit 0190e50
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# cd into root of project
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dir="$(dirname "$script_dir")"
cd "$root_dir"

# Determine the operating system
case "$OSTYPE" in
darwin*) # macOS: activate virtual environment using bin/activate
venv_activate_path="flask-env/bin/activate"
open_command="open"
;;
linux*) # Linux: activate virtual environment using bin/activate
venv_activate_path="flask-env/bin/activate"
open_command="xdg-open"
;;
msys*) # Windows: activate virtual environment using Scripts/activate
venv_activate_path="flask-env/Scripts/activate"
open_command="start"
;;
*) echo "Unsupported operating system" ;;
esac

# Create and activate the virtual environment
python3 -m venv flask-env
source "$venv_activate_path"
pip install -r requirements.txt

# Launch flask
$open_command "http://127.0.0.1:5000"
flask --app server run --debug
30 changes: 30 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Get the root directory of the project
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dir="$(dirname "$script_dir")"
cd "$root_dir"

# Determine the operating system
case "$OSTYPE" in
darwin*) # macOS: activate virtual environment using bin/activate
venv_activate_path="flask-env/bin/activate"
open_command="open"
;;
linux*) # Linux: activate virtual environment using bin/activate
venv_activate_path="flask-env/bin/activate"
open_command="xdg-open"
;;
msys*) # Windows: activate virtual environment using Scripts/activate
venv_activate_path="flask-env/Scripts/activate"
open_command="start"
;;
*) echo "Unsupported operating system" ;;
esac

# Activate the virtual environment
source "$venv_activate_path"

# Launch Flask in a new terminal window
$open_command "http://127.0.0.1:5000"
flask --app server run --debug

0 comments on commit 0190e50

Please sign in to comment.