IIS Deployment Python web framework Flask

Source: Internet
Author: User



IISinstallation will not say it, then run:inetmgr, openIISManager, openWebPlatform Installer, (if not, Baidu download install it), and then install--iis:CGIthis bag.

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/9C/8C/wKiom1lx0RHSHQpVAADNofwl2mM157.png-wh_500x0-wm_ 3-wmp_4-s_225784938.png "title=" 1.png "alt=" Wkiom1lx0rhshqpvaadnofwl2mm157.png-wh_50 "/>


650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/9C/8C/wKiom1lx0Szz9KTrAABUs4NIAlg555.png-wh_500x0-wm_ 3-wmp_4-s_2462057401.png "title=" 2.png "alt=" Wkiom1lx0szz9ktraabus4nialg555.png-wh_50 "/>

    1. Next, add the site, add the handler module mappings:

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/9C/8C/wKiom1lx0UDxk_raAABHVuncsrY225.png-wh_500x0-wm_ 3-wmp_4-s_1124484574.png "title=" 3.png "alt=" Wkiom1lx0udxk_raaabhvuncsry225.png-wh_50 "/>


Be sure to go to the "handler map" in the website console, do not enter directly in the IIS console, or the created fastcgi will take effect for all sites

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/9C/8C/wKioL1lx0VyiKaxEAABsLnzDpxs875.png-wh_500x0-wm_ 3-wmp_4-s_1359204177.png "title=" 4.png "alt=" Wkiol1lx0vyikaxeaabslnzdpxs875.png-wh_50 "/>


on the right, click on "Add Module map", the content is as follows, python Path |wfastcig.py the path to the file.

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/9C/8C/wKiom1lx0ZHSrgoaAAA7UWnhs7c879.png-wh_500x0-wm_ 3-wmp_4-s_3737448814.png "title=" 5.png "alt=" Wkiom1lx0zhsrgoaaaa7uwnhs7c879.png-wh_50 "/>



In the executable column, enter the location of the "Python program" and "wfastcgi.py", fill in the name, and take care not to forget the "|" in the middle. Symbols

After filling out the request limit, call the handler only when the request is mapped to the following: tick off.

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/9C/8C/wKioL1lx0ZGxZEBlAAAzEYbRNt0986.png-wh_500x0-wm_ 3-wmp_4-s_1868184413.png "title=" 6.png "alt=" Wkiol1lx0zgxzeblaaazeybrnt0986.png-wh_50 "/>


Confirm Add will pop up Create fastcgi Application dialog box, click Confirm Create

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/9C/8C/wKiom1lx0ZHBs7BLAAAsQ8y4V-w329.png-wh_500x0-wm_ 3-wmp_4-s_2807414828.png "title=" 7.png "alt=" Wkiom1lx0zhbs7blaaasq8y4v-w329.png-wh_50 "/>


This allows you to see the fastcgi mappings you just added in the handler mappings.

Return to the IIS console and go to "fastcgi settings" to see the mappings you just added


650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/9C/8C/wKioL1lx0ZLAvdDAAADL3T1qwK4062.png-wh_500x0-wm_ 3-wmp_4-s_645594768.png "title=" 8.png "alt=" Wkiol1lx0zlavddaaadl3t1qwk4062.png-wh_50 "/>


Double-click Open, add Flask environment variables at the time of execution

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/9C/8C/wKiom1lx0ZOB5PrsAAB70jMy3AY853.png-wh_500x0-wm_ 3-wmp_4-s_3923376388.png "title=" 9.png "alt=" Wkiom1lx0zob5prsaab70jmy3ay853.png-wh_50 "/>


Only two environment variables are required for flask deployment:

Wsgi_handler corresponds to the location of the flask instance, this is the app in the Flaskweb file

PYTHONPATH for Web site root directory

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/9C/8C/wKioL1lx0ZOTeEDLAABWGtZrgIw122.png-wh_500x0-wm_ 3-wmp_4-s_3109798921.png "title=" 10.png "alt=" Wkiol1lx0zoteedlaabwgtzrgiw122.png-wh_50 "/>


After the configuration is complete, you can also restart IIS or recycle the corresponding process.

Let's talk about how static files are handled, as well as not requiring too many settings to flask the "static" folder under the project as an example

Locate the page for this folder within IIS, open the handler mappings

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/9C/8C/wKiom1lx0ZXCR7IwAABM7ir0oWo456.png-wh_500x0-wm_ 3-wmp_4-s_4031686052.png "title=" 13.png "alt=" Wkiom1lx0zxcr7iwaabm7ir0owo456.png-wh_50 "/>


You can see that the list here is consistent with the site.


The fastcgi map created for the site is deleted, the static folder can be accessed directly, and the right "revert to parent" can revert to this directory modification

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/9C/8C/wKiom1lx0ZWij9rSAABXRJlvO0U723.png-wh_500x0-wm_ 3-wmp_4-s_639349075.png "title=" 14.png "alt=" Wkiom1lx0zwij9rsaabxrjlvo0u723.png-wh_50 "/>





This article from "Lu Yaliang" blog, declined reprint!

IIS Deployment Python web framework Flask

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.