diff --git a/docs/routes.md b/docs/routes.md index ee53a27..a4386e6 100644 --- a/docs/routes.md +++ b/docs/routes.md @@ -103,6 +103,7 @@ You can pass integers, strings, and positive floats with the following types: - str - int - float +- path (see below) A URL can also have multiple capture groups: @@ -113,6 +114,15 @@ def example(request, id, name): ``` In this case, a valid URL might be `/example/3/james`, and both sections will be split out and passed to the view. +The `path` option is special; this is used when you want to capture everything after the slash. For example: + +```python +@app.route("/example/") +def example(request, rest): + return HttpResponse(body=f"Example with {rest}") +``` +It will come in as a string, but it will include all the slashes and other characters that are in the URL. + ## Adding Error Views For some apps, you may want to have your own error views that are themed to your particular application. For this, there's a slightly different process, but the gist is the same. There are also three ways to handle error views, all very similar to adding regular views. @@ -184,4 +194,4 @@ path = app.reverse("example", {'obj_id': 3}, query={'name': 'james'}) print(path) # -> "/example/3?name=james" ``` -The arguments you pass in must match what the path expects, or you'll get a `SpiderwebException`. If there's no route with that name, you'll get a `ReverseNotFound` exception instead. \ No newline at end of file +The arguments you pass in must match what the path expects, or you'll get a `SpiderwebException`. If there's no route with that name, you'll get a `ReverseNotFound` exception instead.