Skip to content

Commit

Permalink
Fix pyright complaints about server.py (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
pydsigner committed Dec 20, 2023
1 parent 35305fb commit 025576b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/anchovy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@

class ThreadedHTTPServer(http.server.ThreadingHTTPServer):
"""
A simple HTTP server that handles each request in a separate thread.
A simple threaded HTTP server with a more powerful handler.
"""
RequestHandlerClass: typing.Type[http.server.SimpleHTTPRequestHandler]
def __init__(self,
server_address: _AfInetAddress,
RequestHandlerClass: typing.Type[http.server.SimpleHTTPRequestHandler],
directory: str | pathlib.Path = '.',
bind_and_activate: bool = True) -> None:
super().__init__(server_address, RequestHandlerClass, bind_and_activate)
super().__init__(server_address, Handler, bind_and_activate)
self.directory = str(directory)

def finish_request(self, request, client_address) -> None:
self.RequestHandlerClass(request, client_address, self, directory=self.directory)
Handler(request, client_address, self, directory=self.directory)


class Handler(http.server.SimpleHTTPRequestHandler):
Expand Down Expand Up @@ -83,7 +81,7 @@ def do_GET(self):


def serve(port: int, directory: str | pathlib.Path, host: str = 'localhost'):
with ThreadedHTTPServer((host, port), Handler, directory=directory) as httpd:
with ThreadedHTTPServer((host, port), directory=directory) as httpd:
print(f'Serving at http://localhost:{port}')
httpd.serve_forever()

Expand Down

0 comments on commit 025576b

Please sign in to comment.