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()
相关推荐
闲人编程1 天前
Python在网络安全中的应用:编写一个简单的端口扫描器
网络·python·web安全·硬件·端口·codecapsule·扫描器
Mr_Xuhhh1 天前
GUI自动化测试--自动化测试的意义和应用场景
python·集成测试
2301_764441331 天前
水星热演化核幔耦合数值模拟
python·算法·数学建模
循环过三天1 天前
3.4、Python-集合
开发语言·笔记·python·学习·算法
Q_Q5110082851 天前
python+django/flask的眼科患者随访管理系统 AI智能模型
spring boot·python·django·flask·node.js·php
躲猫猫的喵喵1 天前
Ubuntu2204降内核版本
linux·运维·服务器·ubuntu
SunnyDays10111 天前
如何使用Python高效转换Excel到HTML
python·excel转html
cccccc语言我来了1 天前
(Linux (6):从包管理到工具探索,构建系统操作基础认知)
linux·运维·服务器
Q_Q5110082851 天前
python+django/flask的在线学习系统的设计与实现 积分兑换礼物
spring boot·python·django·flask·node.js·php
编程社区管理员1 天前
React 发送短信验证码和验证码校验功能组件
前端·javascript·react.js