Skip to content

Commit

Permalink
add RouteDefinition in sample code
Browse files Browse the repository at this point in the history
this helps avoid python/mypy#10740
  • Loading branch information
raylu committed Apr 8, 2024
1 parent 7e338da commit 38f68c7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ pigwig is a WSGI framework for python 3.6+::

#!/usr/bin/env python3

import typing
from pigwig import PigWig, Response
if typing.TYPE_CHECKING:
from pigwig import Request
from pigwig.routes import RouteDefinition

def root(request):
def root(request: Request) -> Response:
return Response('hello, world!')

def shout(request, word):
def shout(request: Request, word: str) -> Response:
return Response.json({'input': word, 'OUTPUT': word.upper()})

routes = [
routes: RouteDefinition = [
('GET', '/', root),
('GET', '/shout/<word>', shout),
]
Expand Down

0 comments on commit 38f68c7

Please sign in to comment.