ftp服务器太慢配置,索性用python做了一个小网站上传简单多了

index.html

html 复制代码
<!DOCTYPE html>  
<html>  
<head>  
    <title>Upload a zip file</title>  
</head>  
<body>  
    <form method="POST" enctype="multipart/form-data">  
        <input type="file" name="file">  
        <button type="submit">Upload</button>  
    </form>  
</body>  
</html>

python 代码

python 复制代码
import tornado.web  
import zipfile  
import os  
  
class UploadHandler(tornado.web.RequestHandler):  
    
    def get(self):
        self.render("index.html")
        
    def post(self):  
        file_name = self.request.files['file'][0]['filename']  
        body = self.request.files['file'][0]['body']  
        with open(file_name, 'wb') as f:  
            f.write(body)  
          
        # 解压文件  
        with zipfile.ZipFile(file_name, 'r') as zip_ref:  
            zip_ref.extractall()  
          
        self.write('File uploaded and unzipped successfully')  
  
def make_app():  
    return tornado.web.Application([  
        (r"/upload", UploadHandler),  
    ])  
  
if __name__ == "__main__":  
    app = make_app()  
    app.listen(5000)  
    tornado.ioloop.IOLoop.current().start()
相关推荐
代码中介商20 分钟前
Linux 帮助手册与用户管理完全指南
linux·运维·服务器
赵侃侃爱分享27 分钟前
学完Python第一次写程序写了这个简单的计算器
开发语言·python
a95114164231 分钟前
Go语言如何操作OSS_Go语言阿里云OSS上传教程【完整】
jvm·数据库·python
2401_8971905532 分钟前
MySQL中如何利用LIMIT配合函数分页_MySQL分页查询优化
jvm·数据库·python
whuhewei34 分钟前
为什么客户端不存在跨域问题
前端·安全
断眉的派大星41 分钟前
# Python 魔术方法(魔法方法)超详细讲解
开发语言·python
妮妮喔妮1 小时前
supabase的webhook报错
开发语言·前端·javascript
我的xiaodoujiao1 小时前
API 接口自动化测试详细图文教程学习系列11--Requests模块3--测试练习
开发语言·python·学习·测试工具·pytest
cccccc语言我来了1 小时前
C++轻量级消息队列服务器
java·服务器·c++
Polar__Star1 小时前
C#怎么使用并发集合 C#ConcurrentDictionary和ConcurrentQueue线程安全集合怎么用【进阶】
jvm·数据库·python