summaryrefslogtreecommitdiff
path: root/cli/serve.py
blob: 9910294c8e55528802b4a804f693f61f58e0cee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from http.server import HTTPServer, SimpleHTTPRequestHandler

from .base import cli


@cli.command()
def serve():
    class BuildHTTPRequestHandler(SimpleHTTPRequestHandler):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, directory="build", **kwargs)

    print("Local server running on http://localhost:8000")
    server_address = ("", 8000)
    httpd = HTTPServer(server_address, BuildHTTPRequestHandler)
    httpd.serve_forever()