扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
windows 7 x64
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的信阳网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
IIS 6
python 2.7.9
wfastcgi-3.0.0
flask-0.12.2
pip install wfastcgi
C:\Users\wangpan>D:\software\Python27\Scripts\wfastcgi-enable.exe
已经在配置提交路径“MACHINE/WEBROOT/APPHOST”向“MACHINE/WEBROOT/APPHOST”的“system.webServer/fastCgi”节应用了配置更改
“d:\software\python27\python.exe|d:\software\python27\lib\site-packages\wfastcgi.pyc” can now be used as a FastCGI script processor
pip install flask
IIS 需要安装 URL 重写组件,这个可以通过Microsoft Web Platform Installer来安装。下载Microsoft Web Platform Installer后运行,搜索URL,安装URL重写工具。
upload
–static上传目录的静态文件目录
–upload.py上传文件程序
–web.config配置文件
注意:
scriptProcessor的内容是执行wfastcgi-enable的输出
WSGI_HANDLER的value
PYTHONPATH的value
WSGI_LOG的目录一定要存在
#_*_coding:utf-8_*_ import os from flask import Flask, request, redirect, url_for,render_template from werkzeug import secure_filename from flask import send_from_directory UPLOAD_FOLDER = 'd:\data\mysite\upload\static' ALLOWED_EXTENSIONS = set(['txt', 'docx', 'doc', 'xlsx' , 'xls','ppt' , 'pdf', 'png', 'jpg', 'jpeg', 'gif']) app = Flask(__name__) app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS @app.route('/', methods=['GET', 'POST']) def upload_file(): if request.method == 'POST': file = request.files['file'] filename = file.filename if file and allowed_file(filename): #filename = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) return redirect(url_for('uploaded_file',filename=filename)) #return redirect('success.html') return '''''' @app.route('/upload/Upload new File Upload new File
http://docs.jinkan.org/docs/flask/
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流