Slighlty less shitty implementation of live reload Signed-off-by: Anirudh <icyph0x@pm.me>
Anirudh icyph0x@pm.me
Sun, 07 Jul 2019 22:57:02 +0530
2 files changed,
8 insertions(+),
7 deletions(-)
M
requirements.txt
→
requirements.txt
@@ -1,4 +1,5 @@
Jinja2==2.10.1 markdown2==2.3.6 MarkupSafe==1.0 +livereload huepy
M
vite/vite.py
→
vite/vite.py
@@ -16,6 +16,7 @@ import datetime
from markdown2 import markdown_path from huepy import * +from livereload import Server # constants@@ -193,16 +194,15 @@ normal_render(f)
def server(): - handler = http.server.SimpleHTTPRequestHandler - os.chdir(os.path.join(os.getcwd(), BUILD_PATH)) +# handler = http.server.SimpleHTTPRequestHandler +# os.chdir(os.path.join(os.getcwd(), BUILD_PATH)) + server = Server() try: - with socketserver.TCPServer(('', PORT), handler) as httpd: - print(run('Serving the {italic} directory at {yellow}'.format(italic(cyan("build"), yellow("http://localhost:{PORT}"))))) - print(white('Ctrl+C') + ' to stop.') - httpd.serve_forever() + print(run(f'Serving the {italic(yellow("build"))} directory at {white(f"http://localhost:{PORT}")}')) + print(white('Ctrl+C') + ' to stop.') + server.serve(port=PORT, root='build/') except KeyboardInterrupt: print(info('Stopping server.')) - httpd.socket.close() sys.exit(1)