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()
相关推荐
朱 欢 庆10 分钟前
云服务器附件备份到本机内网服务器
运维·服务器·前端·经验分享
Sylvia33.12 分钟前
LOL实时数据接入深度解析:从WebSocket到完整数据模型
java·网络·python·websocket·网络协议
梦想不只是梦与想13 分钟前
Web 服务器网关协议:ASGI 和 WSGI
服务器·python·fastapi
智恒百亿17 分钟前
8 卡 RTX 5090 服务器深度实测:256GB 显存能否支撑 70B 模型微调?选型参考
大数据·运维·服务器·人工智能
ai小陈2 小时前
PyTorch DataLoader数据加载性能排查:GPU利用率低的实操指南
人工智能·pytorch·python·深度学习·ai·gpu算力
2601_962299245 小时前
Azure python操作系统列表
python·操作系统·azure·虚拟机·存储配置文件
支支დ6 小时前
VO by Vercel 前端特定优势:为什么它是构建 AI 应用的新范式
前端·人工智能
小诗懂技术6 小时前
【网络通信UDP】基础 进程间不同主机的通信
运维·服务器·网络
weixin_440730506 小时前
selenium实战记录-从登陆-首页-进入应用流程用例三种参数化+日志+报告
服务器·selenium·测试工具
香芋芋圆6 小时前
AI 冲击内卷之下,普通前端如何破局?WebGIS—— 低门槛突围赛道
前端·javascript·人工智能·学习·职场发展