我试图拼凑一个烧瓶应用程序来玩蟒蛇和烧瓶。它有一个复仇者主题(任何人都看到这部电影有多酷?!)。无论如何,当我点击/仪表板路径时,我不断得到500,而且我不确定原因。关心帮助我?
from flask import Flask, render_template, request, abort, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
## ## #### #### ##### #
# # # # # # # ### #
# # #### #### ##### ####
class Ticket(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120), index = True)
name = db.Column(db.String(64), index = True)
whatWentWrong = db.Column(db.String(5000))
def __repr__(self):
return "Ticket"
def __init__(self, email, name, whatWentWrong):
self.email = email
self.name = name
self.whatWentWrong = whatWentWrong
# #### ####
### #### ####
# # # #
@app.route('/')
@app.route('/index')
def activate_shield_defense_mechanism():
return render_template('index.html')
@app.route('/dashboard')
def admin():
try:
data = Ticket.query.all()
except:
data = None
print vars(data)
return render_template('dashboard.html', data=data)
if __name__ == '__main__':
app.run()
C:\ Users \ %%%%%%% \ ShieldVirtualEnv \ Scripts \ python.exe C:/ Users / %%%%%%%%PycharmProjects / SHIELD / SHIELD.py [21 / Apr / 2014 19:52:52]" GET / dashboard HTTP / 1.1" 500 -
答案 0 :(得分:0)
实际上想出来了。在我发布之前,应该再继续玩它20分钟。无论如何,问题是Ticket.query.all()返回一个数组,而不是一个dict,而vars()没有。只需将其更改为print data
就可以了。