400 Bad Request:浏览器(或代理)发送了本服务器无法理解的请求
400 Bad Request: The browser (or proxy) sent a request that this server could not understand
我正在尝试在 Flask 应用程序中构建一个电影推荐系统。但是,我收到以下错误:
BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a
request that this server could not understand.
这是我的代码。
app.py
predictor.html
sample.py
终端视图
浏览器视图
你可以试试这个:
@app.route('/', methods=['GET','POST'])
def predict():
if 'movie_input' in request.form:
movies = similar_movies(request.form['movie_input'])
else:
movies = "No movies selected. Please, select something!"
print(movies)
return render_template('predictor.html', movie_input=movies)
此代码将处理未提供 movie_input 的情况(例如在第一页加载期间)
我正在尝试在 Flask 应用程序中构建一个电影推荐系统。但是,我收到以下错误:
BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
这是我的代码。 app.py
predictor.html
sample.py
终端视图
浏览器视图
你可以试试这个:
@app.route('/', methods=['GET','POST'])
def predict():
if 'movie_input' in request.form:
movies = similar_movies(request.form['movie_input'])
else:
movies = "No movies selected. Please, select something!"
print(movies)
return render_template('predictor.html', movie_input=movies)
此代码将处理未提供 movie_input 的情况(例如在第一页加载期间)