all repos — py-vite @ ee0ec1fa8f781c7d9de33cd13d9de0ce23108bff

the original vite, written in python

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
commit

ee0ec1fa8f781c7d9de33cd13d9de0ce23108bff

parent

5c92bb4a985e676cb6362b040d7d0454f5e29e60

2 files changed, 8 insertions(+), 7 deletions(-)

jump to
M requirements.txtrequirements.txt

@@ -1,4 +1,5 @@

Jinja2==2.10.1 markdown2==2.3.6 MarkupSafe==1.0 +livereload huepy
M vite/vite.pyvite/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)