DEV Community

MATHIVATHANA S
MATHIVATHANA S

Posted on

1

How to setup simple flask application

What is flask?
Flask is one of the lightweight framework of python, which is based on web application,(i.e) can build web applications using python with flask application.

  1. Create a folder of your choice
  2. Create file name app.py
  3. Insert the below code
from flask import Flask  // importing Flask class from flask 
app = Flask(__name__)   //

@app.route('/') //decorator tells Flask what URL should trigger our function.
def hello_world():
    return 'Hello, World!'

if __name__ == "__main__":
    app.run(debug=True)  // starts flask dev. server with debug mode to log errors.
Enter fullscreen mode Exit fullscreen mode
  1. open the root folder of app.py eg: flask_app/
  2. run this on terminal
pip install flask
python app.py
Enter fullscreen mode Exit fullscreen mode
  1. open browser, navigate to http://127.0.0.1:5000/ , you will see output Hello, World! [due to technical difficulties could not able to attach the screenshot]

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay