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 分钟前
Flutter for OpenHarmony 实战:按钮类 Widget 完全指南
前端·javascript·flutter
馨谙6 分钟前
shell编程实际应用----磁盘空间监控与告警
linux·运维·服务器
css趣多多6 分钟前
Vux store实例的模块化管理
前端
lixin55655618 分钟前
基于神经网络的音乐生成增强器
java·人工智能·pytorch·python·深度学习·语言模型
养海绵宝宝的小蜗19 分钟前
Python第二次作业
开发语言·python
我的xiaodoujiao21 分钟前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 43--添加allure测试报告显示信息和其他封装方法
python·学习·测试工具·allure
无垠的广袤22 分钟前
【CPKCOR-RA8D1】RUHMI 转换 AI 模型
人工智能·python·嵌入式硬件·开发板
aiguangyuan26 分钟前
从词袋到TF-IDF:sklearn文本特征工程实战指南
人工智能·python·nlp
UP_Continue30 分钟前
Linux--命令行参数和环境变量
linux·运维·服务器
数据知道34 分钟前
PostgreSQL 实战:详解 UPSERT(INSERT ON CONFLICT)
数据库·python·postgresql