Windows 10 使用IIS部署flask网站

开始

启用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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值