Construction of Flask development environment under window

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.