Welcome to the Flask tutorial section! Flask is a lightweight web application framework for Python. It is highly flexible and easy to use, making it a popular choice for web development. In this guide, we will walk you through the basics of getting started with Flask.

What is Flask?

Flask is a micro web framework for Python based on WSGI. It's intended to be easy to get started with, and flexible enough to meet the needs of advanced users. Flask does not include templates or databases by default, allowing you to choose the ones that are best suited for your project.

Quick Installation

To get started with Flask, you'll need to install it using pip. Open your terminal or command prompt and run the following command:

pip install flask

Creating Your First Flask Application

After installing Flask, you can create a simple application in a single file. Let's name our file app.py.

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, Flask!'

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

This is a basic Flask application that responds to requests at the root URL (/) with "Hello, Flask!".

Running Your Application

Save the above code as app.py in a directory of your choice. Navigate to that directory in your terminal or command prompt and run the following command:

python app.py

You should see output similar to the following:

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now, open a web browser and go to http://127.0.0.1:5000/. You should see the message "Hello, Flask!" displayed.

Further Reading

If you want to learn more about Flask, we recommend checking out the official Flask documentation. It provides comprehensive guides and resources to help you dive deeper into the framework.

Continue to Flask Templates to learn how to create dynamic web pages with Flask.


Python Programming