FLASK ON IIS
来源:互联网 发布:重庆大学软件学院 编辑:程序博客网 时间:2024/06/10 18:19
http://netdot.co/2015/03/09/flask-on-iis/
While Windows Server is usually not my preferred OS for deploying Python based web[sites|services] sometimes the situation dictates it. For situations where that is the case I’ve usually reached for Apache with mod_python until now. FastCGI is relatively straightfoward to setup on Windows Server 2012R2 and IIS using the Microsoft Web Platform Installer.
(NOTE: I’m using Flask, but any WSGI compatible Python app will work the same way)
Installing IIS
You’ll need to make sure that IIS is installed and configured with the CGI role service (this enables FastCGI as well).
Go to Server manager -> Manage -> Add Roles and Features:
Choose Role-based or feature-based installation:
Select your server:
Choose “Web Server (IIS)”:
Click “Add Features”:
Accept the defaults until you reach the “Role Services” screen. At this point make sure “CGI” is selected:
Click next, accept defaults and click “Install”. You should see this screen:
Launch the IIS Manager:
If this message pops up, click “Yes” - otherwise you’ll need to download and install the Web Platform Installer if you haven’t already installed it:
Run the installer
Search for WFastCGI
Select the appropriate Python version (3.4 or 2.7.9). We’ll choose 3.4. Click “Add”, then click “Install”.
Read and accept the license (if you want to continue):
Once you’re done - you should see this screen:
Setup your site - copy the wfastcgi.py from C:\Python34 (may be named C:\Python34_x86 if you had an existing Python34 directory) to your Flask application root:
Double click “Handler Mappings”
Click “Add Module Mapping”
Click “Request Restrictions”. Make sure “Invoke handler only if request is mapped to:” checkbox is unchecked:
Click “Yes” here:
Go to the root server settings and click “FastCGI Settings”:
Double click it, then click the “…” for the Environment Variables collection to launch the EnvironmentVariables Collection Editor:
Set the PYTHONPATH variable:
And the WSGI_HANDLER (my Flask app is named app.py so the value is app.app - if yours is named site.py it would be site.app or similar):
Click OK and browse to your site:
Flask code below:
from flask import Flaskapp = Flask(__name__)@app.route("/")def hello(): return "Hello from FastCGI via IIS!"if __name__ == "__main__": app.run()
- FLASK ON IIS
- Publish Flask on IIS
- flask-on-iis
- Flask on SAE
- Flask and PostgreSQL on Heroku
- 2017IIS+python+flask环境搭建
- Flask、uWSGI and Nginx on Ubuntu 14.04
- install PHP on the IIS
- How do I deploy a Flask application in IIS?
- flask
- flask
- Flask
- Flask
- flask
- flask
- Flask
- Flask
- flask
- opencv 查找并绘制轮廓
- 练习5
- 基于BootstrapValidator的数据验证
- 运算符的运用
- [BZOJ] 1303
- FLASK ON IIS
- strcat()函数原代码解析
- Nginx源码剖析之内存池、内存管理
- Python入门(三)
- NOIP2017滚粗记
- Windows7系统禁用驱动程序签名强制的方法
- The system is running in low-graphics mode
- golang+walk根据数据库表生成java,proto和模板
- 爬取Ajax界面