Flask app仍然以500,Heroku结束

时间:2015-01-07 10:39:11

标签: python heroku flask gunicorn

仍在获取这些日志,但我的500页扩展了我的base.html

2015-01-07T10:21:31.317465+00:00 heroku[router]: at=info method=GET path="/" host=sheltered-ravine-5921.herokuapp.com request_id=60e4b20d-f93a-408c-b8de-282c5efc52ce fwd="193.179.215.98" dyno=web.1 connect=2ms service=95ms status=500 bytes=1493
2015-01-07T10:21:31.527501+00:00 heroku[router]: at=info method=GET path="/static/ico/favicon.ico" host=sheltered-ravine-5921.herokuapp.com request_id=e461e7e0-6cf6-4cc5-b9a5-17ae826da9e0 fwd="193.179.215.98" dyno=web.1 connect=2ms service=5ms status=500 bytes=1493 

我的主文件

import os
import psycopg2

from flask import Flask, render_template, send_from_directory
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
db = SQLAlchemy(app)

from views import *

db.drop_all()
db.create_all()

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

和views.py

import os
from flask import Flask, render_template, send_from_directory
from flask import session, request, flash, url_for, redirect, render_template, abort ,g
from flask.ext.login import login_user , logout_user, current_user, login_required
from flask.ext.login import LoginManager
from jdutrunit import app, db
from models import User

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

@login_manager.user_loader
def load_user(id):
    return User.query.get(int(id))

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

@app.route('/favicon.ico')
def favicon():
    return send_from_directory(os.path.join(app.root_path, 'static/ico/favicon.ico'))

@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

@app.errorhandler(500)
def internal_error(error):
    db.session.rollback()
    return render_template('500.html'), 500

应用树

├── Procfile
├── forms.py
├── hello.py
├── jdutrunit.py
├── models.py
├── notes.txt
├── requirements.txt
├── static
│   └── ico
│       └── favicon.ico
├── templates
│   ├── 404.html
│   ├── 500.html
│   ├── base.html
│   ├── index.html
│   ├── login.html
│   └── register.html
└── views.py

所以我仍然无法弄清楚为什么https://sheltered-ravine-5921.herokuapp.com/不能留在index.html上

{% extends "base.html" %}
{% block title %} - Home {% endblock %}
{% block content %}
<h2>Ahoooj valecniku</h2>
{% endblock %}

我不知道如何从gunicorn获得最大值,从heroku获取日志

web: gunicorn jdutrunit:app --log-file=- --debug --error-logfile /tmp/gunicornerror --log-level debug

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我明白了,遗漏了一部分:

app.secret_key = 'abrakadabra'