2017-02-10 80 views
1

我正在刷我的烧瓶技能来制作一个“危险分数守护者”应用程序。我现在想要做的是从数据库中获取玩家的分数并将其显示在屏幕上。我不断收到“404 NOT FOUND”错误。这里是我的代码:烧瓶:我为什么会收到404错误?

JeopardyApp.py

@app.route('/layout', methods=['POST']) 
def layout(): 
    db = get_db() 
    try: 
     cur1 = db.execute('SELECT score FROM {tn} where name="Tyler"'.format(tn="Score")) 
     score1 = cur1.fetchone() 
    except: 
     flash("This person doesn't exist in our database!") 
    return render_template('layout.html', score=score1) 

的layout.html

<!doctype html> 
<title>JeopardyApp</title> 
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"> 
<div class=page> 
    <h1>Jeopardy Score Keeper</h1> 
    <div class=metanav> 
    <p>Currently under construction...</p> 
    </div> 

    <div> 
    <p>Tyler</p> 
      <tr><td>{{ score.score }}</td></tr> 
    </div> 

    {% for message in get_flashed_messages() %} 
    <div class=flash>{{ message }}</div> 
    {% endfor %} 
    {% block body %}{% endblock %} 
</div> 

任何帮助表示赞赏。谢谢。

回答

0

您为layout功能设置的路线只能通过POST方法访问。 默认情况下,您的网页浏览器使用GET方法。

改变你的路线是这样的:

@app.route('/layout', methods=['GET']) 
+0

我试过了,我仍然得到同样的错误:( – HereComesDatBoi

+0

这应该实际工作是您使用的URL来调用'layout'端点 – MrLeeh

+0

?我不知道我做了什么,但我确实得到了这个工作,我认为我的URL或app.route是不正确的,但是,我现在很好,谢谢! – HereComesDatBoi