Spaces:
Runtime error
Runtime error
Download src/main.py from connor-33341/BambuLabFailureDetection: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/connor-33341/BambuLabFailureDetection/resolve/main/src/main.py
- Command line
-
hf download hf://spaces/connor-33341/BambuLabFailureDetection/src/main.py
-
curl -L -o main.py https://huggingface.co/spaces/connor-33341/BambuLabFailureDetection/resolve/main/src/main.py
1.01 kB
| from http.server import BaseHTTPRequestHandler, HTTPServer | |
| import urllib.parse | |
| class RequestHandler(BaseHTTPRequestHandler): | |
| def do_GET(self): | |
| self.send_response(200) | |
| self.send_header('Content-type', 'text/html') | |
| self.end_headers() | |
| self.wfile.write(b"<html><body><h1>GET request received</h1></body></html>") | |
| def do_POST(self): | |
| content_length = int(self.headers['Content-Length']) | |
| post_data = self.rfile.read(content_length) | |
| parsed_data = urllib.parse.parse_qs(post_data.decode('utf-8')) | |
| self.send_response(200) | |
| self.send_header('Content-type', 'text/html') | |
| self.end_headers() | |
| response = f"<html><body><h1>POST request received</h1><p>{parsed_data}</p></body></html>" | |
| self.wfile.write(response.encode('utf-8')) | |
| def run_server(): | |
| server_address = ('localhost', 8000) | |
| httpd = HTTPServer(server_address, RequestHandler) | |
| print("Serving on port 8000...") | |
| httpd.serve_forever() | |
| run_server() | |