Azad Rasul
SmartRS

Follow

SmartRS

Follow

3- Create Hello World App in Flask

Azad Rasul's photo
Azad Rasul
·Jan 3, 2023·

1 min read

Play this article

To create Hello World app in Flask, First, import the Flask class from the flask package:

from flask import Flask

Then, set the app as an instance of Flask:

app = Flaks(__name__)

Define a function index route to display “Hello, World! This is my first from Flask”:

@app.route("/")
def hello():
        return 'Hello, World! This is my first app from Flask.'

Save a script as “hello.py

Then run the script with cmd using:

python hello.py

Now open your internet browser and write:

http://192.168.100.2:5000

or localhost:5000

Your first web page should be opened like this:

To quit running it press CTRL+C

The complete code is:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
        return 'Hello, World! This is my first app from Flask.'

if __name__ == "__main__":
        app.run(debug=True)

* If you like the content, please SUBSCRIBE to my channel for the future content

 
Share this