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 小时前
如何用企业微信实现让微信收到通知实时通知
服务器·python·微信小程序·fastapi
牢姐与蒯5 小时前
Linux进程间通信(三).基于匿名管道的进程池的实现
linux·运维·服务器·ubuntu
mldong5 小时前
给流程设计器加国际化,我没引 vue-i18n
前端·javascript·vue.js
IMPYLH5 小时前
HTML 的 <strong> 元素
前端·html
P.D.Wei5 小时前
[Leetcode 3524] 求出数组的X值I
python·学习
weixin199701080167 小时前
《二手ERP对接闲鱼API:聚石塔强制入塔后的架构重构实录》(附Python源码)
python
小白快快跑哦7 小时前
python-字符串全解(六):正则表达式-转义与非转义
python·正则表达式·转义与非转义
开开心心就好11 小时前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
IvanCodes13 小时前
Python 数据处理(十三):JSON、CSV 与数据序列化
开发语言·python
Setsuna_F_Seiei13 小时前
前端转型 Agent 开发 05 之 Agent Hooks 与 Checkpointer(让 Agent 从全自动转变人为可掌控)
前端·agent·ai编程