Olá,
Eu tentei fazer a atividade dessa aula retirando a parte de traduzir, e sempre recebo o erro no endereço http://127.0.0.1:5000/sentimento/love:
TypeError TypeError: The view function did not return a valid response. The return type must be a string, dict, list, tuple with headers or status, Response instance, or WSGI callable, but it was a float.
O código completo:
from flask import Flask
from textblob import TextBlob
app = Flask("__name__")
@app.route("/")
def home():
return "first api"
@app.route("/sentimento/<sentence>")
def sentimento(sentence):
tb = TextBlob(sentence)
polaridade = tb.sentiment.polarity
return "polaridade: {}".format(polaridade)
app.run(debug = True)