Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/examples/mnist/server.py # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / examples / mnist / server.py` 36 lines ยท 1200 bytes Raw Blame History 1 import http.server 2 import socketserver 3 import os 4 import sys 5 6 DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), 'web')) 7 PORT = 8000 8 9 class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): 10 def __init__(self, *args, **kwargs): 11 super().__init__(*args, directory=DIRECTORY, **kwargs) 12 13 def end_headers(self): 14 # Add required headers for SharedArrayBuffer 15 self.send_header("Cross-Origin-Opener-Policy", "same-origin") 16 self.send_header("Cross-Origin-Embedder-Policy", "require-corp") 17 self.send_header("Access-Control-Allow-Origin", "*") 18 super().end_headers() 19 20 # Enable address reuse 21 class CustomServer(socketserver.TCPServer): 22 allow_reuse_address = True 23 24 try: 25 with CustomServer(("", PORT), CustomHTTPRequestHandler) as httpd: 26 print(f"Serving directory '{DIRECTORY}' at http://localhost:{PORT}") 27 print(f"Application context root: http://localhost:{PORT}/") 28 try: 29 httpd.serve_forever() 30 except KeyboardInterrupt: 31 print("\nServer stopped.") 32 # Force complete exit 33 sys.exit(0) 34 except OSError as e: 35 print(f"Error: {e}") 36 sys.exit(1)