File: sink_example.py

package info (click to toggle)
python-hug 2.6.0-2.4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,072 kB
  • sloc: python: 8,938; sh: 99; makefile: 17
file content (11 lines) | stat: -rw-r--r-- 412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
"""This is an example of a hug "sink", these enable all request URLs that start with the one defined to be captured

To try this out, run this api with hug -f sink_example.py and hit any URL after localhost:8000/all/
(for example: localhost:8000/all/the/things/) and it will return the path sans the base URL. 
"""
import hug


@hug.sink("/all")
def my_sink(request):
    return request.path.replace("/all", "")