DEV Community


Creating a new Flask project with pipenv

therealdarkmage profile image darkmage ・1 min read
  • Create the pipenv environment
$ mkdir project
$ cd project
$ pipenv install

  • Install Flask
$ pipenv install flask

  • Structure folders/files:
mkdir app
touch app/
touch app/

  • In app/
from flask import Flask

app = Flask(__name__)

from app import routes

  • In app/
from app import app

def index():
    return "Hello, World!"

  • In
from app import app

  • Change into the pipenv:
$ pipenv shell

  • Set the FLASK_APP variable:
$ export

  • Run the app:
$ flask run

Now, whenever you need to extend your Flask app to import some new libraries or framework or whatever, just install it using pipenv.

This whole process inspired me to write a bash script that does all this automatically for you. Why make things harder than they need to be?

Grab and give it a spin on your system to quickly get a barebones Hello World project in Flask started today!

If you need a Computer Science tutor, code reviewer, or just someone to pair program with, hit me up

Discussion (0)

Forem Open with the Forem app