2

Building a basic Flask application involves creating a new Flask object and defining one or more routes and views.

Here is an example of a basic Flask application: 

In this example, we first import the Flask module and create a new Flask object named “app”. We then define two routes, “/” and “/about”, using the @app.route decorator. Each route is associated with a function, called a view, which returns a response to the client. In this case, the views return the rendered templates index.html and about.html respectively.

You will also need to create the templates (index.html and about.html) in a folder named templates in the same directory as your app.py file.

When the application is run, navigating to “http://localhost:5000” in the browser will execute the index() function and return the rendered index.html template. Navigating to “http://localhost:5000/about” will execute the about() function and return the rendered about.html template.

This is a basic example of a Flask application, and you can build upon this basic structure to create more complex applications.

Leave a Reply

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