Uttar Pradesh, India
Instagram

Hello World Flask

In this tutorial, you’ll learn how to create a simple web app with Python Flask.

Flask is a micro-framework called.

It has a small core but is extensible with many plugins such as SQLAlchemy, Babel, MongoDB, etc.

 

Why Flask?

  • Easy to use.
  • built-in with development server and debugger
  • integrated unit testing support
  • RESTful request dispatching
  • uses Jinja2 templating
  • support for secure cookies (client-side sessions)
  • Unicode based
  • Clear documented

Installing Flask

Install Flask using the command below:

pip install Flask

Flask Say hello world app

Create a file called say-hello.py

from flask import Flask
app = Flask(__name__)

@app.route("/")
    def hello():
        return "Hello World!"

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

Go to the windows command prompt and run the web app using below command:

python say-hello.py

Command prompt showing below URL

* Running on http://localhost:5000/

Just navigate to this URL on the browser. http://localhost:5000/  “Hello World!” should appear.


Comments

Share your thoughts in the comments

Your email address will not be published. Required fields are marked *