#!/usr/bin/python3#encoding:utf-8
#來自官網,但官網的不能直接用,稍微修改了一下,秒秒鐘執行成功,哈哈哈哈
import os
from flask import flask, request, redirect, url_for
from werkzeug.utils import secure_filename
from flask import send_from_directory
upload_folder = './static/uploads'#上傳到這裡
allowed_extensions = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif','jpeg','rar','doc','docx','dot','pptx','db'])#允許的格式,保證安全性
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in allowed_extensions
def upload_file():
if request.method == 'post':
file = request.files['file']
if file and allowed_file(file.filename):
#filename = secure_filename(file.filename)
filename =request.form['filename']#檔名,支援中文哦!!!
filename =str(filename)#防止惡意傳送非正常字元導致伺服器異常
return redirect(url_for('uploaded_file',
filename=filename))
return '''
上傳檔案'''
def uploaded_file(filename):
filename)
if __name__=='__main__':
Python 利用pymmseq cpp實現分詞
在python這pymmseg cpp 還是十分方便的!環境 ubuntu10.04 python2.65 步驟 2 tar zxf pymmseg cpp tar.gz 解壓後得到pymmseg 目錄 cd pymmseg mmseg cpp python build.py 生成 mmseg.so...
flask利用裝飾器實現自定義路由
當我們使用flask實現restful介面時,並要求對檢視函式做特殊裝飾處理,這時需要我們通過flask利用裝飾器實現自定義路由 softcomaiweb包下 softcomaiweb.py from flask import flask import uuid route index1 metho...
flask利用session身份偽造
想研究很久了,這次終於初步了解了flask session偽造 得知道金鑰 python2和python3 session解密不一樣,而且不都是base64,指令碼 參考文章 flask是把session存在客戶端的,而且只經過base64編碼和用金鑰簽名,雖然沒有有簽名不可以偽造session,但...