Skip to content

Instantly share code, notes, and snippets.

@ak-seyam
Last active September 25, 2020 11:03
Show Gist options
  • Save ak-seyam/8142c673e05364c879194518f5a45fa9 to your computer and use it in GitHub Desktop.
Save ak-seyam/8142c673e05364c879194518f5a45fa9 to your computer and use it in GitHub Desktop.
# simple flask dev init script
echo "Remember: you MUST source this script instead of running it in a sub shell if you are going to use it inside the */__init__.py"
echo "--------------------------------------------------"
export FLASK_ENV=development
if test -f __init__.py; then
wd=`pwd`
cd "$wd/.."
export FLASK_APP=`basename $wd`
echo "INFO: flask app initialized in the current dir you have redirected to the parent dir"
flask run
else
if [[ $# -eq 0 ]]; then
echo "Error Flask App name should be provided if there is no __init__.py in the current directory"
echo -e "Usage: \n<path/to/the/script/>flask_init.sh [Name]\nName: the name of your application it is optional if this scripts runs in a directory with __init__.py in it bacause it uses the folder name as the app name"
exit 1
fi
export FLASK_APP=$1
flask run
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment