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()
相关推荐
非优秀程序员4 小时前
第10章 千团出世|《互联网产品恩仇录》
前端
非优秀程序员4 小时前
第11章 小高在对面|《互联网产品恩仇录》
前端
非优秀程序员4 小时前
第14章 只剩美团|《互联网产品恩仇录》
前端
非优秀程序员4 小时前
第09章 老乡何必为难老乡|《互联网产品恩仇录》
前端
非优秀程序员5 小时前
第03章 三大门户,烽烟起于瀛海威|《互联网产品恩仇录》
前端
知已难寻5 小时前
Docker 入门:容器技术与 Docker 基础
java·运维·服务器·docker·云原生·容器
曦樂~9 小时前
【Web Development】02 CSS
前端·css
风骏时光牛马9 小时前
后端服务接口开发与数据逻辑处理
前端
东鹏特饮9 小时前
经典打砖块(Breakout)游戏
前端·css·css3
IT_陈寒9 小时前
Vite的HMR把我整不会了:一个生产环境的热更新坑
前端·人工智能·后端