首页 > 解决方案 > python烧瓶和pyrebase中的Seek()错误

问题描述

我是python和flask API开发的新手。我创建了一个 API,它在上传图像后通过 html 发布表单接受图像我将该图像传递给枕头库以调整大小,但是当我使用 .put() 方法将图像存储到 pyrebase 时收到 seek() 错误我的代码:

import requests
from PIL import Image
from file import ImgId
import pyrebase
import io



config={
"apiKey": "AIzaSyBvlJpkV7rcYwbx3wNEBARKvrpHMBALXuw",
    "authDomain": "allinonetools.firebaseapp.com",
   "databaseURL": "https://allinonetools-default-rtdb.firebaseio.com",
    "projectId": "allinonetools",
   "storageBucket": "allinonetools.appspot.com",
}

firebase = pyrebase.initialize_app(config)

app = Flask(__name__)


storage=firebase.storage()


@app.route('/')
def home():
    return render_template('index.html')
    

@app.route("/size", methods=["POST"])
def process_image():
    file = request.files['image']
    # Read the image via file.stream
    img = Image.open(file.stream)
    new_image = img.resize((400, 400))
    img_url=ImgId()
    storage.child(img_url).put(img)
    

    return jsonify({'msg': 'success', 'size': [new_image.width, new_image.height]})
   


if __name__ == "__main__":
    app.run(debug=True) 
This is the error

我的错误

标签: pythonapiflaskjpeg

解决方案


推荐阅读