55
66from errno import EAGAIN , ECONNRESET
77
8+ from .methods import HTTPMethod
89from .request import _HTTPRequest
910from .response import HTTPResponse
1011from .status import HTTPStatus
@@ -26,11 +27,11 @@ def __init__(self, socket_source: Any) -> None:
2627 self ._sock = None
2728 self .root_path = "/"
2829
29- def route (self , path : str , method : str = " GET" ):
30+ def route (self , path : str , method : HTTPMethod = HTTPMethod . GET ):
3031 """Decorator used to add a route.
3132
3233 :param str path: filename path
33- :param str method: HTTP method: " GET", " POST" , etc.
34+ :param HTTPMethod method: HTTP method: HTTPMethod. GET, HTTPMethod. POST, etc.
3435
3536 Example::
3637
@@ -99,7 +100,7 @@ def poll(self):
99100 route = self .routes .get (request , None )
100101 if route :
101102 response = route (request )
102- elif request .method == " GET" :
103+ elif request .method == HTTPMethod . GET :
103104 response = HTTPResponse (filename = request .path , root = self .root_path )
104105 else :
105106 response = HTTPResponse (status = HTTPStatus .INTERNAL_SERVER_ERROR )
0 commit comments