ktongue's picture
download
raw
1 kB
#!/usr/bin/env python3
"""Serve the repository and open the static STL viewer for a given file.
Usage:
python serve_viewer.py --file cylinder.stl --port 8000
"""
import http.server
import socketserver
import webbrowser
import argparse
import os
p = argparse.ArgumentParser(description='Serve repo and open static STL viewer')
p.add_argument('--file', '-f', default='cylinder.stl', help='STL filename to load (relative to repo root)')
p.add_argument('--port', '-p', type=int, default=8000)
args = p.parse_args()
cwd = os.getcwd()
viewer_url = f'http://localhost:{args.port}/examples/viewer_stl.html?file={args.file}'
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", args.port), Handler) as httpd:
print(f"Serving {cwd} at http://localhost:{args.port}")
print(f"Opening viewer: {viewer_url}")
webbrowser.open(viewer_url)
try:
httpd.serve_forever()
except KeyboardInterrupt:
print('\nStopping server')
httpd.server_close()

Xet Storage Details

Size:
1 kB
·
Xet hash:
a7baf19f8565351d961c1abddf057981ce0d13295f1a2dd70bd1bd0f4010ef00

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.