tinyweb
tinyweb copied to clipboard
Support for multiple params in url and added method to obtain query string as dictionary
Adds ability to specify multiple parameter names
@app.resource('/cmnd/<device>/<state>')
def cmndstate(data, device, state):
return {'device': device, 'state': state}
Adds ability to obtain query string as a dictionary from request object.
@app.route('/cmnd')
async def cmnd(request, response):
d = request.read_parse_query_data()
await response.start_html()
await response.send(f"<html><body><h1>{d}</h1></body></html>")
It looks like we could get away with storing just the parameter count in params['_param_names']. I can't see the param names being used anywhere else. Perhaps change this to params['_param_count']. It could then be used to pass the correct number of arguments to the user's route function.