DEV Community

Manthan Ankolekar
Manthan Ankolekar

Posted on

Set-up Flask & Print Hello World!

Virtual environments

Create an environment :

//In Windows
> mkdir myproject
> cd myproject
> py -3 -m venv venv
Enter fullscreen mode Exit fullscreen mode

Activate the environment :

> venv\Scripts\activate
Enter fullscreen mode Exit fullscreen mode

Install Flask :

pip install Flask
Enter fullscreen mode Exit fullscreen mode

Hello World! in Flask :

//save as hello.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"
Enter fullscreen mode Exit fullscreen mode

Run the application:

flask --app hello run
Enter fullscreen mode Exit fullscreen mode

Screenshots :

Image description

Image description

Top comments (0)