+5 votes
308 views
Install FLASK on Windows 10

in Windows 10 by (551k points)
reopened | 308 views

1 Answer

+3 votes
Best answer

How to install Flask on Windows

We have thousands of applications available to increase both the capacity of the system and our own and one of these strong segments is the creation of web applications. These entail a series of key requirements so that everything works correctly, both in terms of permissions and accessibility, and for everything to work as expected we have Flask..

 

What is Flask
Flask is a framework that has been written in Python thanks to which we have the best options for creating web applications quickly, not only quickly but without having to enter and edit too many lines of code.

 

Flask is based on Werkzeug's WSGI specification as well as the Jinja2 template engine, it has a BSD license. By using Flask, we will be having tools, libraries and technologies with which to create a web application will be something simple.

 

 

Flask components
Flask is made up of two elements that are:

 

  • Werkzeug which is a library of utilities to be integrated with the Python language, acts as a web server gateway interface or a WSGI application to create software elements.
  • Jinja which is a template engine for Python programming.

 

 

 

Flask Features
Among its characteristics we highlight:

 

  • It is based on Unicode
  • Allows the execution of individual tests
  • Compliant with WSGI
  • It has development servers and debugging functionalities
  • Use Jinja2 template styles
  • Allows the creation of secure cookies for sites

 

 

 

To stay up to date, remember to subscribe to our YouTube channel!   SUBSCRIBE

 

 

How to install Flask on Windows

 

Step 1

The first requirement is to have Python, in case of not having Python we can go to the following link:

 

 Python

 

image

 

Step 2

We download the most recent version and the installation wizard will be displayed:

 

image

 

Step 3

We select "Install Now" to proceed with the installation of Python in Windows 10:

 

image

 

Step 4

At the end we will see the following:

 

image

 

Step 5

We will do this process if we do not have Python on the system. Once we have Python, we will create a folder where the application configuration will be hosted, in this case we have created one in Documents called "flask_app", after this we access the terminal and there we will go to the path of the created folder (using cd) and execute the following:
 py -m venv env 
image

 

 

Step 6

This will create the virtual environment of Flask, we go to the folder and observe the content:

 

image

 

 

Step 7

When double clicking on it we see its configuration files:

 

image

 

Step 8

We return to the terminal and activate the environment with the following command:
 env \ Scripts \ activate 
image

 

 

Step 9

We install Flask with the following command:
 pip install flask 
image

 

 

Note
at the bottom it is recommended to update pip to the most current version.

 

Step 10

With some advanced editor, we recommend Sublime Text, we create a new file called app.py and save it in the folder created said .py file:

 

image

 

Step 11

We establish the application with the following command:
 set FLASK_APP = app.py 
image

 

 

Step 12

Now we go to the file with the editor and enter the following:
 from flask import Flask app = Flask (__ name__) @ app.route ('/') def index (): return '<h1> Hello! <h1>' 
image

 

Step 13

To run this environment we will go to the terminal and there we execute:
 flask run 
image

 

 

Step 14

We have in mind the IP assigned there, we open a browser and when entering this address we will see the following:

 

image

 

 

Step 15

Now it is possible to add something else to our file, we set a name variable, we enter this:
 from flask import Flask app = Flask (__ name__) @ app.route ('/ name') def index (<name>): return '<h1> Hello {}! <h1>'. format (name) 
image

 

 

Step 16

We save the changes, close the current process in the terminal with Ctrl + C and again execute:

 

 

Ctrl + R

 flask run 

image

 

 

Step 17

Now in the browser we must enter the following. We can see the change, if we do not establish the name an error will appear.
 http: //127.0.01: 5000 / name 

image

 

With this we have learned to install Flask in Windows 10 and have a tool to create websites..

 


by (3.5m points)

Related questions

+3 votes
1 answer
asked Oct 26, 2020 in Windows 10 by backtothefuture (551k points) | 404 views
+5 votes
1 answer
asked Oct 26, 2020 in Windows 10 by backtothefuture (551k points) | 907 views
+3 votes
1 answer
asked Oct 26, 2020 in Windows 10 by backtothefuture (551k points) | 283 views
+5 votes
1 answer
asked Oct 26, 2020 in Windows 10 by backtothefuture (551k points) | 204 views
+3 votes
1 answer
asked Oct 26, 2020 in Windows 10 by backtothefuture (551k points) | 317 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,632 questions
10,764 answers
510 comments
3 users