簡體   English   中英

內部服務器錯誤Flask

[英]Internal server error Flask

第一次學習Flask,我正在嘗試按照教程構建東西。 當我輸入這個網址時,我在瀏覽器中收到此消息:

http://127.0.0.1:5000/index 

127.0.0.1 - - [16/Jun/2014 19:37:41] "GET /index HTTP/1.1" 500 -

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

我不知道為什么我會收到這個錯誤。 有人能幫幫我,告訴我為什么嗎? 我是Flask和Web開發的新手

碼:

from flask import Flask, request, make_response, redirect, render_template
from flask.ext.script import Manager
from flask.ext.bootstrap import Bootstrap


app = Flask(__name__)
manager = Manager(app)
bootstrap = Bootstrap(app)

@app.route('/index')
def index():
    return render_template('index.html')

@app.route('/user/<name>')
def user(name):
    return render_template('user.html', name = name)

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

index.html的:

{% extends "base.html" %}

{% block title %} Index {% block title %}

{% block head %}
    <!-- Uses super() to retain the original contents-->
    {{ super() }}
    <style type="text/css">

    </style>
{% endblock %}  
{% block body %}
<h1>Hello, World!</h1>
{% endblock %}

這是我的項目結構:

/Flask_0_11
   /templates
      base.html
      index.html
      user.html
   hello.py

index.html存在模板語法錯誤。

應使用{% endblock %}關閉標題{% endblock %}

{% block title %} Index {% endblock %}

您可以打開DEBUG配置進行調試。 因為您使用Flask-Script ,所以可以將-d選項傳遞給runserver命令。

例如

python hello.py runserver -d

首先嘗試使用運行應用程序

python manage.py runserver -d

這將以調試模式運行您的燒瓶應用程序,顯示您的應用程序中遇到的錯誤,輕松進行更正。

其次,由於配置文件中沒有WTF_CSRF_ENABLED = True和SECRET_KEY,可能會出現錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM