我有此服务器代码,在其中使用“ add_url_rule”添加视图功能。
class EditedListModel: public QAbstractListModel
{
bool EditedListModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
bool retVal = false;
if( index.isValid() )
{
// Some condition which allows item selection
if( ... )
m_ItemSelected[index.row()] = data.toBool();
}
return retVal;
}
}
这是我的处理函数:
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_url_rule('/etsiproxy/notify/<vnf_id>',
view_func=handle_sol003_notifications,
methods=['GET', 'POST'])
app.server = 'tornado'
# This is run from a different thread, create a default event loop for
# this thread for tornado.
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
self.threadLoop = loop
# Flask with Tornado works in single thread. Use the thread to store
# the server object, so that it can be accessed from the handler
thr = threading.current_thread()
thr.api_provider = self
app.run(server='tornado', port=self._port, host=self._host, debug=False)
在此URL上发帖请求时,我将收到此错误: TypeError:视图函数未返回有效响应。 这是因为我返回None,而flask不喜欢这个。
但是如果我使用 return'',204 ,则会出现另一个错误,提示无法使用204发送正文。
在这种情况下如何退回204没有内容?