mirror of
https://github.com/rizinorg/rizin
synced 2026-08-22 20:26:16 -04:00
32 lines
636 B
Python
32 lines
636 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
|
||
|
|
r"""
|
||
|
|
This script launches python -m http.server in a subprocess and waits until it's ready to receive
|
||
|
|
a new connection.
|
||
|
|
|
||
|
|
"""
|
||
|
|
|
||
|
|
import http.client
|
||
|
|
import subprocess
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
subprocess.run(
|
||
|
|
"python3 -m http.server 9000 --bind 127.0.0.1 &",
|
||
|
|
shell=True,
|
||
|
|
check=True,
|
||
|
|
cwd="www",
|
||
|
|
stdout=subprocess.DEVNULL,
|
||
|
|
stderr=subprocess.DEVNULL,
|
||
|
|
)
|
||
|
|
while True:
|
||
|
|
try:
|
||
|
|
http.client.HTTPConnection("127.0.0.1", 9000, timeout=5).connect()
|
||
|
|
except ConnectionRefusedError:
|
||
|
|
continue
|
||
|
|
break
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|