53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
NetVM Docs HTTP Server (bl)
|
||
|
|
|
||
|
|
Serves markdown documentation for agents via HTTPS (tailnet).
|
||
|
|
- Central repo: ~/Projects/NetVM/
|
||
|
|
- Serves: *.md, docs/*.png
|
||
|
|
- Read-only, no auth (tailnet is the auth boundary)
|
||
|
|
|
||
|
|
GOLDEN PATH: container -> VM (34.139.37.135) -> bl (100.123.153.75) -> this server
|
||
|
|
|
||
|
|
Usage:
|
||
|
|
python3 netvm-docs-server.py [--port 8080]
|
||
|
|
|
||
|
|
Agents fetch via:
|
||
|
|
curl http://0.0.0.0:8080/ACCOUNTS.md
|
||
|
|
"""
|
||
|
|
import http.server
|
||
|
|
import socketserver
|
||
|
|
import os
|
||
|
|
import argparse
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
class DocsHandler(http.server.SimpleHTTPRequestHandler):
|
||
|
|
def __init__(self, *args, **kwargs):
|
||
|
|
# Serve from NetVM repo root
|
||
|
|
self.base_dir = Path.home() / "Projects" / "NetVM"
|
||
|
|
super().__init__(*args, directory=str(self.base_dir), **kwargs)
|
||
|
|
|
||
|
|
def log_message(self, format, *args):
|
||
|
|
# Quiet logging
|
||
|
|
pass
|
||
|
|
|
||
|
|
def end_headers(self):
|
||
|
|
# Allow CORS for browser agents
|
||
|
|
self.send_header('Access-Control-Allow-Origin', '*')
|
||
|
|
super().end_headers()
|
||
|
|
|
||
|
|
def main():
|
||
|
|
p = argparse.ArgumentParser()
|
||
|
|
p.add_argument('--port', type=int, default=8080)
|
||
|
|
args = p.parse_args()
|
||
|
|
|
||
|
|
# Only bind to tailnet interface (not public)
|
||
|
|
# 100.123.153.75 is bl's tailnet IP
|
||
|
|
with socketserver.TCPServer(("0.0.0.0", args.port), DocsHandler) as httpd:
|
||
|
|
print(f"Serving NetVM docs on http://0.0.0.0:{args.port}/")
|
||
|
|
print(f"Directory: {Path.home()}/Projects/NetVM/")
|
||
|
|
httpd.serve_forever()
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
main()
|