Forums

Web app shows a 500 error on the browser but works on console

Greetings. Im new at this. Im trying to test a webapp that reads a saved model and returns data. At this point I made a basic testing function that uploads the model and shows the intercept on screen. When I run the function hello_world() from the console, it shows the intercepts. When I run the browser, I get a 500 error. Am I missing something basic and important? Any help will be really apreciate. This is my code now:

from flask import Flask
import pickle
app = Flask(__name__)
@app.route('/')
def hello_world():
    model_pkl = open("/home/martinsgattoni/mysite/modelo_saved.pkl","rb")
    model = pickle.load(model_pkl)
    test = model.intercept_
    return test

[edit by admin: formatting]

you can only return strings with flask.

Oh, so the problem is the object, right? I show deconstruct it. I suspected it was something dumb. I really apreciate your help. Thanks.