1. Install Python
Download https://www.python.org/downloads/, follow the prompts to install the line, remember the installation directory, add it to the system path.
2. Install Pip
Download pip file on official website: https://bootstrap.pypa.io/get-pip.py, run the installation Pip:python directly at the command line get-pip.py
3, Installation Virtualenv
Run command: Pip intall virtualenv Direct installation
Run the Create Virtual Environment command: Virtualenv venv, a venv folder is successfully produced in the current directory.
Open Virtual Environment: first CD venv, enter the Venv directory, enter Scripts\activate run, open successfully.
Turn off the virtual environment: Enter deactivate carriage return to close successfully.
As shown in the following:
After the virtual environment is created successfully, the virtual environment is opened, and the command line has the environment name (VENV), which can install various packages freely in the virtual environment without affecting the host Python environment.
4, Installation Flask
After the virtual environment is turned on, run PIP Intall flask to install directly.
As shown in the following:
5. Hello World
Write the following code with notepad++:
From flask Import Flaskapp = Flask (__name__) @app. Route ('/') def index (): return ' index Page ' @app. Route ('/hello ') def Hello (): return ' Hello, world ' if __name__ = = "__main__": App.run ()
Save As hello.py and run Python hello.py on the command line:
Start successfully, accessible in the browser, enter Http://127.0.0.1:5000/hello, route to the Hello function:
OK, stay tuned for the following episode ~ ~:)
Construction of Flask development environment under window