python flask创建服务器实现文件的上传下载,已获千赞

avatar
作者
筋斗云
阅读量:1

}

二、后端代码(python)

import os

from re import template

from string import Template

from flask import Flask, send_file,request,jsonify

from werkzeug.utils import secure_filename

from flask_cors import CORS

import time

app = Flask(name)

absolute = os.path.dirname(file)

CORS(app)

app.debug = True

定义文件的保存路径和文件名尾缀

FOLDER = os.path.join(absolute, ‘save_file’)

HOST = “localhost”

PORT = 8080

UPLOAD = ‘upload’

app.config[‘UPLOAD’] = UPLOAD

basedir = os.path.abspath(os.path.dirname(file))

ALLOWED_EXTENSIONS = set([‘txt’,‘png’,‘xls’,‘xlsx’,‘jpeg’,‘jpg’])

进行文件类型判断的函数

def a

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!