MCPcopy Index your code
hub / github.com/RustPython/RustPython / test

Function test

Lib/http/server.py:1332–1362  ·  view source on GitHub ↗

Test the HTTP request handler class. This runs an HTTP server on port 8000 (or the port argument).

(HandlerClass=BaseHTTPRequestHandler,
         ServerClass=ThreadingHTTPServer,
         protocol="HTTP/1.0", port=8000, bind=None,
         tls_cert=None, tls_key=None, tls_password=None)

Source from the content-addressed store, hash-verified

1330
1331
1332def test(HandlerClass=BaseHTTPRequestHandler,
1333 ServerClass=ThreadingHTTPServer,
1334 protocol="HTTP/1.0", port=8000, bind=None,
1335 tls_cert=None, tls_key=None, tls_password=None):
1336 """Test the HTTP request handler class.
1337
1338 This runs an HTTP server on port 8000 (or the port argument).
1339
1340 """
1341 ServerClass.address_family, addr = _get_best_family(bind, port)
1342 HandlerClass.protocol_version = protocol
1343
1344 if tls_cert:
1345 server = ServerClass(addr, HandlerClass, certfile=tls_cert,
1346 keyfile=tls_key, password=tls_password)
1347 else:
1348 server = ServerClass(addr, HandlerClass)
1349
1350 with server as httpd:
1351 host, port = httpd.socket.getsockname()[:2]
1352 url_host = f'[{host}]' if ':' in host else host
1353 protocol = 'HTTPS' if tls_cert else 'HTTP'
1354 print(
1355 f"Serving {protocol} on {host} port {port} "
1356 f"({protocol.lower()}://{url_host}:{port}/) ..."
1357 )
1358 try:
1359 httpd.serve_forever()
1360 except KeyboardInterrupt:
1361 print("\nKeyboard interrupt received, exiting.")
1362 sys.exit(0)
1363
1364if __name__ == '__main__':
1365 import argparse

Callers 1

server.pyFile · 0.70

Calls 6

_get_best_familyFunction · 0.85
printFunction · 0.50
getsocknameMethod · 0.45
lowerMethod · 0.45
serve_foreverMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected