python开发webservice接口 实现文件上传_Python如何使用Flask模块将文件上传到webservice?...

I'm following this tutorial on how to set up file uploading webservice using Flask。下面是我的代码片段。我可以看到def upload_file():获得了正确的文件名并允许它通过,但是,实际保存文件的行没有执行,我收到“Internal server error(500)”响应。问题似乎是在磁盘上实际存储文件。在

我还需要做些什么来设置我的web服务来使用Flask保存接收到的文件?

已更新-下面的代码现在起作用from flask import Flask

from flask import Response, jsonify, request, redirect, url_for

#persistent storage in dictionary

import shelve

#printing ip of host

import socket

#file uploading

import os

from werkzeug.utils import secure_filename

#serving files that were uploaded

from flask import send_from_directory

#mac-specific relative path to the script's location

UPLOAD_FOLDER = './audio'

ALLOWED_EXTENSIONS = set(['txt', 'm4a', 'mp4'])

#configuration

app = Flask(__name__)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值