开始
启用CGI
安装URL重写组件
https://www.microsoft.com/web/downloads/platform.aspx
安装wfastcgi
pip install wfastcgi
启用wfastcgi
以管理员身份启动cmd
切换到wfastcgi-enable.exe路径下
d:
cd D:\main\Anaconda3\envs\Bert-BiLSTM-CRF-pytorch\Scripts
wfastcgi-enable
已经在配置提交路径“MACHINE/WEBROOT/APPHOST”向“MACHINE/WEBROOT/APPHOST”的“system.webServer/fastCgi”节应用了配置更改
"d:\main\anaconda3\envs\bert-bilstm-crf-pytorch\python.exe|d:\main\anaconda3\envs\bert-bilstm-crf-pytorch\lib\site-packages\wfastcgi.py" can now be used as a FastCGI script processor
d:\main\anaconda3\envs\bert-bilstm-crf-pytorch\python.exe|d:\main\anaconda3\envs\bert-bilstm-crf-pytorch\lib\site-packages\wfastcgi.py 下面的步骤需要使用
Tips: 使用命令 wfastcgi-disable 可以将其移除。
创建web.config文件
参考模板
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- scriptProcessor 的值来自命令行工具 wfastcgi-enable -->
<add name="FlaskFastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python34\python.exe|C:\Python34\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<security>
<!-- URL 重写中的特殊字符,比如加号+等等 -->
<requestFiltering allowDoubleEscaping="true"></requestFiltering>
</security>
</system.webServer>
<appSettings>
<!-- Required settings -->
<!-- 在这里指定Falsk app在模块中的具体位置 -->
<add key="WSGI_HANDLER" value="hello.app" />
<add key="PYTHONPATH" value="~/" />
<!-- Optional settings -->
<!-- 需要先创建日志目录,否则报错 -->
<add key="WSGI_LOG" value="C:\logs\oboeqa_web.log" />
<add key="WSGI_RESTART_FILE_REGEX" value="" />
</appSettings>
</configuration>
配置IIS目录及权限
进入到项目路径下:
icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)"
已处理的文件: .
已成功处理 1 个文件; 处理 0 个文件时失败
icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"
已处理的文件: .
已成功处理 1 个文件; 处理 0 个文件时失败
创建并访问你的网站
开放端口
https://jingyan.baidu.com/article/3c343ff75a0f3b4d36796359.html
参考资料
在Windows平台使用IIS部署Flask网站
https://cloud.tencent.com/developer/article/1589220
windows IIS部署python Flask网站
https://blog.csdn.net/david_lee13/article/details/81985847