Flask 应用程序仍然以 500 结束,Heroku
Flask app still end on 500, Heroku
仍在获取这些日志,但我的 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
感谢帮助
我明白了,缺少部分:
app.secret_key = 'abrakadabra'
仍在获取这些日志,但我的 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
感谢帮助
我明白了,缺少部分:
app.secret_key = 'abrakadabra'