关于烧瓶安息

时间:2016-12-07 06:49:33

标签: flask-restful

客户端使用get函数:

def get_hist_data(exchange_id, instrument_id, frequency, start_date, end_date):
    headers = fill_header()
    body =

    {'exchange_id':exchange_id,'instrument_id':instrument_id,
    'star``t_date':start_date,'end_date':end_date,'frequency':frequency}
    resp = requests.get(stock_tick_url,json.dumps(body), headers=headers)
    print resp.text
Sever side:

结果是没有时间打印args'。我知道如果客户端代码更改为:?xx=xxx&xxx=xxxx服务器将起作用。但改为json,它不起作用。

任何人都可以帮助我?

1 个答案:

答案 0 :(得分:0)

parser = reqparse.RequestParser() parser.add_argument(' exchange_id',type = str,location =' args')

parser.add_argument(' instrument_id',type = str,location =' args')

parser.add_argument(' start_date',type = str,location =' args')

parser.add_argument(' end_date',type = str,location =' args')

parser.add_argument(' frequency',type = int,location =' args')

def get(self):     args = parser.parse_args()