-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_http2_debug.py
More file actions
executable file
·34 lines (26 loc) · 901 Bytes
/
test_http2_debug.py
File metadata and controls
executable file
·34 lines (26 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3.13
"""Test HTTP/2 server with debug logging"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from fasterapi._native.http2 import PyHttp2Server
def hello_handler(method, path, headers, body):
return {
"status": 200,
"headers": {"content-type": "text/plain"},
"body": "Hello from HTTP/2!\n"
}
def main():
server = PyHttp2Server(port=8080, num_pinned_workers=2)
# Register handlers
server.register_handler("GET", "/", hello_handler)
print("[Python] Starting HTTP/2 server on 0.0.0.0:8080")
print("[Python] Press Ctrl+C to stop")
print("[Python] Test with: curl --http2-prior-knowledge http://localhost:8080/")
try:
server.start()
except KeyboardInterrupt:
print("\n[Python] Stopping server...")
server.stop()
if __name__ == "__main__":
main()