[web2py] Re: service function with header key

2018-04-03 Thread 黄祥
after several test and relearn from the book *controllers/api.py* def http_api_key(): api_key = request.env.http_api_key # change api_key with the parameter you want in curl request header if api_key == 'your_api_key': query = (db.table0.id > 0) rows = db(query).select() else: rows =

[web2py] Re: service function with header key

2018-03-31 Thread 黄祥
this post clearer than before *controllers/api.py* @service.json def get_table(table_name, id): response.headers['key'] = '123' return dict(content = db[table_name](id) ) *terminal* curl -X GET --user admin:password -i http://127.0.0.1:8000/test/api/call/json/get_table/table0/1 --header 'key: