tinyweb icon indicating copy to clipboard operation
tinyweb copied to clipboard

Support for multiple params in url and added method to obtain query string as dictionary

Open Beormund opened this issue 3 years ago • 1 comments

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>")

Beormund avatar Nov 16 '22 15:11 Beormund

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.

Beormund avatar Nov 16 '22 23:11 Beormund