Quick Start Automation

Start here for your 1st flask script
Every time I want to start a flask project I will create a directory strucutre and create files. Copy the quick start tempalate from Flask docs and then run the app. Too much work, right?
So I've automated it by adding a small script to my ~/.zshrc file. If you are using bash this will be ~/.bashrc for you
Add the following to your rc file
~/.bashrc or ~/.zshrc
flaskapp() {
mkdir $1
cd $1
python3 -m venv venv
source venv/bin/activate
pip install flask
// echo command starts here
echo "
from flask import Flask
app = Flask(__name__)
def hello_world():
return '<p>Hello, World!</p>'
def show_user_profile(username):
# show the user profile for that user
return f'User {escape(username)}'
def show_post(post_id):
# show the post with the given id, the id is an integer
return f'Post {post_id}'
if __name__ == '__main__':, debug=True)
" >
// echo command ends here
Run source ~/.zshrc or restart your terminal

Setup The App

Now everytime you need a new app all you have to do is go to your terminal and write
  • It will create a new directory
  • Create a virtualenv
  • Create a sample hello world file

Run the App


Test the API

  1. 1.
    Open the browser
  2. 2.
    Hit the following URLs