2014-06-17 3 views
5

처음으로 Flask를 학습하고 튜토리얼을 따라 물건을 만들려고합니다. 이 URL을 입력하면 브라우저에이 메시지가 나타납니다.내부 서버 오류 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. 

왜이 오류가 발생하는지 잘 모르겠습니다. 누군가 나를 도울 수 있었고 그 이유를 말해 줄 수 있었습니까? 나는 플라스크에 새로운 오전 및 웹 개발

코드 :

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을 :

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

답변

8

템플릿 구문 오류가 있습니다 : 이것은 내 프로젝트 구조입니다

{% 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 %} 

index.html에 있습니다.

는 제목 블록은 {% endblock %} 폐쇄해야합니다

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

당신은 디버깅을 위해 DEBUG 구성을 설정할 수 있습니다. Flask-Script을 사용하기 때문에 -d 옵션을 runserver 명령에 전달할 수 있습니다.

우선

python hello.py runserver -d 
3

이 앱을 쉽게 보정을 만드는 발생한 오류를 보여주는 디버그 모드에서 플라스크 응용 프로그램을 실행합니다

python manage.py runserver -d 

사용하여 응용 프로그램을 실행하려고합니다.

두 번째로 설정 파일에 WTF_CSRF_ENABLED = True 및 SECRET_KEY 오류가있을 수 있습니다.