我该如何着手解决这个问题?我不知道这是什么意思。在
File "/Users/kritikasingh/Desktop/Bucketlist/app/init.py", line 13, in create_app app.config.from_object(app_config[config_name]) TypeError: 'module' object has no attribute 'getitem'
这是它指出问题所在的代码
def create_app(config_name):
from app.models import Bucketlist
app = FlaskAPI(__name__, instance_relative_config=True)
app.config.from_object(app_config[config_name])
app.config.from_pyfile('config.py')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
@app.route('bucketlists/', methods=['POST', 'GET'])
def bucketlists():
if request.method == "POST":
name = str(request.data.get('name', ''))
if name:
bucketlist = Bucketlist(name=name)
bucketlist.save()
response = jsonify({
'id': bucketlist.id,
'name': bucketlist.name,
'date_created': bucketlist.date_created,
'date_modified': bucketlist.date_modified
})
response.status_code = 201
return response
else:
#GET
bucketlists = Bucketlist.get_all()
results = []
for bucketlist in bucketlists:
obj = {
'id': bucketlist.id,
'name': bucketlist.name,
'date_created': bucketlist.date_created,
'date_modified': bucketlist.date_modified
}
results.append(obj)
response = jsonify(results)
response.status_code = 200
return response
return app
错误消息指出配置文件有问题。看看app峎u config[config_file]你可能有个打字错误。看起来您希望使用方法
get_item
,而是将get_item作为某个属性来查找。在你想去哪里
^{pr2}$或者其他类似的东西。搜索文本
get_item
相关问题 更多 >
编程相关推荐