在下面的代碼中,我想將URL存儲在一個變量中,以檢查發生哪個URL錯誤的錯誤。如何獲得燒瓶中的當前基礎URI?
@app.route('/flights', methods=['GET'])
def get_flight():
flight_data= mongo.db.flight_details
info = []
for index in flight_data.find():
info.append({'flight_name': index['flight_name'], 'flight_no': index['flight_no'], 'total_seat': index['total_seat'] })
if request.headers['Accept'] == 'application/xml':
template = render_template('data.xml', info=info)
xml_response = make_response(template)
xml_response.headers['Accept'] = 'application/xml'
logger.info('sucessful got data')
return xml_response
elif request.headers['Accept'] == 'application/json':
logger.info('sucessful got data')
return jsonify(info)
輸出: **
* Restarting with stat
* Debugger is active!
* Debugger PIN: 165-678-508
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [28/Mar/2017 10:44:53] "GET /flights HTTP/1.1" 200 -
**
我想這個消息"127.0.0.1 - - [28/Mar/2017 10:44:53] "GET /flights HTTP/1.1" 200 -"
應存放在一個變量或我怎樣才能得到正在執行當前的URL。 謝謝
127.0.0.1 - - [28/MAR/2017十時44分53秒] 「GET /航班HTTP/1.1」 200 -...如果想要返回整個事物,那我該怎麼辦? –
@RaviBhushan我不知道任何方法來捕獲瓶服務器的標準輸出。 –
好的.... thanx回答 –