[RISE] 14주차 활동내용

세휘·2021년 6월 12일
0

RISE 프로젝트

목록 보기
12/12

.png 파일 업로드시 발생하는 오류 해결



.png파일 업로드

FileNotFoundError 발생



upload.py 수정

from flask import Flask, render_template, request
from predict_food2 import predict_food

app = Flask(__name__)

@app.route('/upload')
def basic():
    return render_template("upload.html")

@app.route('/predict', methods=['POST'])
def predict():
    f = request.files['file']
    Path = "./"
    f.save(Path+f.filename)
    result = predict_food(f.filename)

    # formatting the results as a JSON-serializable structure:
    output = {'result': [result]}

    return output

if __name__ == '__main__':
    app.run(debug=True)

수정 후 결과

0개의 댓글