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()
相关推荐
Railshiqian1 分钟前
UserPickerActivity 内部逻辑分析
开发语言·python
Dlrb12115 分钟前
信息查询Web服务器-->电子商城信息查询项目
linux·服务器·数据库·html·嵌入式·epoll·数据查询
一tiao咸鱼8 分钟前
前端转 agent # 02 - FastAPI 框架入门与原理
前端·python
wanghowie14 分钟前
LangGraph4j 落地(二)— ReAct 多步工具与 trace 扩展
前端·react.js·前端框架
Yolo566Q29 分钟前
Noah-MP陆面过程模型建模方法与站点、区域模拟实践技术应用
开发语言·python
大家的林语冰33 分钟前
Rust 再次打败 Go,Astro 7 首发,什么叫“万物皆可锈化“!
前端·javascript·性能优化
lichenyang45334 分钟前
H5 如何调用 ArkTS:JavaScriptProxy、requestId 和 Promise 回调
前端
lichenyang45335 分钟前
我在 HarmonyOS 上写了一个轻量级小程序运行时:从 Web 容器到 JSBridge
前端
雪隐35 分钟前
用Flutter做背单词APP-02我画了设计稿,然后让AI帮我设计了数据库(顺便聊了会天)
前端·人工智能·后端
lichenyang45336 分钟前
不要把 JSBridge 写成 if else:Dispatcher、Registry 和 Biz/Imp 分层
前端