Flask Tutorial
About Lesson

In this Flask Tutorial we are going to learn about Flask Introduction & Installation, we will learn that how you can install Flask and how you can create your first project in Flask. so Flask is a web framework. This means flask provides you with tools, libraries and technologies that allow you to build a web application. This web application can be some web pages, a blog, a wiki or go as big as a web-based calendar application or a commercial website. Flask is part of the categories of the micro-framework. Micro-framework are normally framework with little to no dependencies to external libraries. This has pros and cons. Pros would be that the framework is light, there are little dependency to update and watch for security bugs, cons is that some time you will have to do more work by yourself or increase yourself the list of dependencies by adding plugins.




You can use simply pip for installing flask.



After installation, you need to open an IDE, iam using Pycharm IDE, but you can use what IDE you want. create a new Python file at name of app.py, now this is our complete code.




All Flask Applications must create an application object, The web server passes all
requests it receives from clients to this object for handling, using a protocol called Web Server Gateway Interface (WSGI). you can create the application object like this.


The only required argument to the Flask class constructor is the name of the main module or package of the application. For most applications, Python’s __name__ variable
is the correct value.


Also for every Flask Application we need to define routes, you can use app.route decorator for creating  routes in Flask, which registers the decorated function as a rout. as we have already done in our above complete code like this.


In the above code we have registered the function Index() as the handler for the applications’s root URL. functions like Index() are called view functions. a response returned by a view function can be a simple string with HTML content, but it can also take more complex forms.



At the end we need to run our web application using development server.



The __name__ == ‘__main__‘  is used here to ensure that the development web server is started only when the script is executed directly, and also you can see that we have made debugging mode True, but when you are going to publish your web application , you need to make false, for development purposes you can keep it true.




Run your code and go to http://localhost:5000/.

Flask Introduction & Installation
Flask Introduction & Installation





Also you can create different routes.