Home > Article > Backend Development > How to install flask
To install Flask, you can follow the following steps: 1. Make sure Python is installed; 2. Open the command line terminal; 3. Enter the "pip install flask" command to install Flask; 4. Wait for the installation to complete. .
# Operating system for this tutorial: Windows 10 system, Dell G3 computer.
To install Flask, you can follow the steps below:
Make sure Python is installed. Flask is a Python-based web framework, so Python needs to be installed first. You can download and install Python from the official Python website (https://www.python.org).
Open a command line terminal (Command Prompt or PowerShell for Windows, Terminal for Mac).
Enter the following command at the command line to install Flask:
pip install flask
This will use the pip package manager to install Flask from the Python Package Index (PyPI ) Download and install Flask.
Now, you have successfully installed Flask. You can create a Flask application and start developing web applications.
The following is an example of a simple Flask application:
from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello, World!' if __name__ == '__main__': app.run()
Save the above code as a Python file (such as app.py), and then run the following command in the command line to start the application :
python app.py
Flask will run on localhost and listen on the default port (5000). You can view the application's output by visiting http://localhost:5000 in your browser.
This is just a simple example, you can extend and customize your Flask application according to your needs.
The above is the detailed content of How to install flask. For more information, please follow other related articles on the PHP Chinese website!