(directory)
| 595 | # you clone a website then run it in that web server, it will pull any index.html file |
| 596 | # |
| 597 | def start_web_server(directory): |
| 598 | try: |
| 599 | # import the threading, socketserver, and simplehttpserver |
| 600 | import socketserver |
| 601 | import http.server |
| 602 | # create the httpd handler for the simplehttpserver |
| 603 | # we set the allow_reuse_address incase something hangs can still bind |
| 604 | # to port |
| 605 | |
| 606 | class ReusableTCPServer(socketserver.TCPServer): |
| 607 | allow_reuse_address = True |
| 608 | # specify the httpd service on 0.0.0.0 (all interfaces) on port 80 |
| 609 | httpd = ReusableTCPServer( |
| 610 | ("0.0.0.0", 80), http.server.SimpleHTTPRequestHandler) |
| 611 | # thread this mofo |
| 612 | os.chdir(directory) |
| 613 | thread.start_new_thread(httpd.serve_forever, ()) |
| 614 | |
| 615 | # handle keyboard interrupts |
| 616 | except KeyboardInterrupt: |
| 617 | print_info("Exiting the SET web server...") |
| 618 | httpd.socket.close() |
| 619 | |
| 620 | # |
| 621 | # this will start a web server without threads |
no test coverage detected