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()
相关推荐
天渺工作室5 小时前
实现一个adblock/adblock plus等浏览器广告拦截器检测插件
前端·javascript
阳光是sunny6 小时前
Vue 项目怎么做用户行为全链路监控?轻量插件方案详解
前端·面试·架构
ZhengEnCi6 小时前
Q04-Vite禁用CSS代码分割-解决生产环境样式加载顺序混乱问题
前端·vue.js·vite
九酒6 小时前
AI Agent 开发踩坑记:口播功能非得用 APP 原生实现吗?
前端·人工智能·agent
Jackson__7 小时前
做了一段时间的AI coding后,我终于搞清了 CLI 和 MCP 的区别
前端·agent·ai编程
IT_陈寒9 小时前
JavaScript项目实战经验分享
前端·人工智能·后端
用户479492835691510 小时前
6w star,GitHub 趋势第一的 Ponytail,这个agent插件到底在火什么
前端·后端
薛定喵的谔11 小时前
我开源了一个精致的 Next.js 博客模板:Skyplume
前端·前端框架·next.js
Warson_L11 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅11 小时前
海天线算法的前世今生
python·计算机视觉