【发布时间】:2014-01-15 11:21:52
【问题描述】:
尝试在 PyCharm 中设置一个基本的烧瓶 (Python) 应用
下面是使用我已经知道的一些 Python 修改的基本“Hello world”应用程序。
我将返回 'Hello world!' 更改为 return contacts 以尝试将我的字典打印到空白页上,但出现 500 服务器错误。
我的基本错误是什么?
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
contacts = dict()
johnSmith = dict()
jasonBourne = dict()
lisbethSalander = dict()
johnSmith['label'] = 'John Smith'
johnSmith['phone'] = '(222) 333-4444'
johnSmith['email'] = 'john@johnsmith.net'
jasonBourne['label'] = 'Jason Bourne'
jasonBourne['phone'] = '(333) 444-5555'
jasonBourne['email'] = 'jason@cia.gov'
lisbethSalander['label'] = 'Lisbeth Salander'
lisbethSalander['phone'] = '(444) 555-6666'
lisbethSalander['email'] = 'lsalander@gmail.com'
contacts['1'] = johnSmith
contacts['2'] = jasonBourne
contacts['3'] = susanBoom
print contacts
return contacts
# return 'Hello world!'
if __name__ == '__main__':
app.run()
错误
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
app.py 第 203 行似乎发生了错误
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
【问题讨论】: