1 from http.server
import HTTPServer, BaseHTTPRequestHandler
5 class Serv(BaseHTTPRequestHandler):
8 self.
path =
'/index.html' 11 file_path = self.
path[1:]
13 with open(file_path,
'rb')
as file:
14 file_to_open = file.read()
16 mime_type, _ = mimetypes.guess_type(file_path)
18 self.send_response(200)
20 self.send_header(
"Content-type", mime_type)
23 self.wfile.
write(file_to_open)
25 except FileNotFoundError:
26 self.send_response(404)
27 self.send_header(
"Content-type",
"text/html")
29 self.wfile.
write(bytes(
"File not found",
'utf-8'))
31 except Exception
as e:
32 self.send_response(500)
33 self.send_header(
"Content-type",
"text/html")
35 self.wfile.
write(bytes(f
"Internal server error: {str(e)}",
'utf-8'))
37 httpd = HTTPServer((
'localhost', 65432), Serv)
38 print(
"Server started at http://localhost:65432")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)