prompt_template/web/serve.py

35 lines
980 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""
Minimaler Entwicklungs-Server für die Prompt Templates Webansicht.
Startet auf Port 8080 und dient die statischen Dateien aus.
"""
import http.server
import socketserver
import os
PORT = 8080
DIRECTORY = os.path.dirname(os.path.abspath(__file__))
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=DIRECTORY, **kwargs)
def do_GET(self):
# Für Root-Pfad: index.htmlservieren
if self.path == '/' or self.path == '/index.html':
self.path = '/index.html'
return super().do_GET()
def main():
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving Prompt Templates on http://localhost:{PORT}")
print(f"Press Ctrl+C to stop")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("\nServer stopped")
if __name__ == "__main__":
main()