原来想这用django 写一个web 应用措施,便于打点mongodb的数据。功效django 不直接撑持mongodb……又没时间研究NoSQL。于是想着随便整个api吧……
于是先用flask 做个简单的demo 部署到本地尝尝水
简单的demofrom flask import Flask, jsonify app = Flask(__name__) tasks = [ { ‘id‘: 1, ‘title‘: u‘Buy groceries‘, ‘description‘: u‘Milk, Cheese, Pizza, Fruit, Tylenol‘, ‘done‘: False }, { ‘id‘: 2, ‘title‘: u‘Learn Python‘, ‘description‘: u‘Need to find a good Python tutorial on the web‘, ‘done‘: False } ] @app.route(‘/‘) def hello_world(): return jsonify({‘task‘:tasks}) if __name__ == ‘__main__‘: app.run()
走进部署之坑网上八门五花的部署blog……各类转载…… 借鉴一下吧
安置IIS
启用CGI
安置Microsoft Web Platform Installer
添加 url 重写(URL Rewrite)和IIS(CGI)
安置 wfastcgi (pip install wfastcgi)
启用 wfastcgi
创建web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<!-- name 和 path 都是项目名 ;scriptProcessor 就是上面启动wfastcgi 的返回信息(如上图,画线部分)-->
<add path="DMApi" verb="*" modules="FastCgiModule" scriptProcessor="e:\demo\flask\dmapi\venv\scripts\python36.exe|e:\demo\flask\dmapi\venv\lib\site-packages\wfastcgi.py" resourceType="File" />
<!-- scriptProcessor 的值来自命令行工具 wfastcgi-enable -->
<add path="*" verb="*" modules="FastCgiModule" scriptProcessor="e:\demo\flask\dmapi\venv\scripts\python36.exe|e:\demo\flask\dmapi\venv\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="DMApi.app" />
<add key="PYTHONPATH" value="~/" />
<!-- Optional settings -->
<!-- 需要先创建日志目录,否则报错 -->
<add key="WSGI_LOG" value="F:\\Demo\\flask\\DMApi\\logs\\web.log" />
<add key="WSGI_RESTART_FILE_REGEX" value="" />
</appSettings>
</configuration>
配置IIS 目录及权限
创建网站
访谒失坑人家教程里写的好好的 “hello ……”
而我倒是这样的
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
是这样的……
功效This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
Add Application Development from the Features! Remember to add the 4.5 stuff if you need it
解决方案就是安置一下asp.net……
终于看到了功效……
windows 10 部署flask web
标签:
原文地点:https://www.cnblogs.com/taoyoung/p/8797455.html