sanic版: # -*- coding: utf-8 -*- import os from sanic import Sanic from sanic.response import redirect, html app = Sanic() @app.route('/', methods=['POST', 'GET']) async def upload(request): if request.method == 'POST': f = request.files.get("file") basepath = os.path.dirname(__file__) upload_path = os.path.join(basepath, 'static', f.name) print(f.name) print(f.type) print(f.body) with open(upload_path, 'wb') as fw: fw.write(f.body) return redirect(app.url_for('upload')) return html(""" <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>文件上传</h1> <form action="" enctype='mult
sanic 与 flask 上传文件服务的区别
最新推荐文章于 2024-04-27 19:49:34 发布