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

Function browse

Lib/pydoc.py:2722–2754  ·  view source on GitHub ↗

Start the enhanced pydoc web server and open a web browser. Use port '0' to start the server on an arbitrary port. Set open_browser to False to suppress opening a browser.

(port=0, *, open_browser=True, hostname='localhost')

Source from the content-addressed store, hash-verified

2720
2721
2722def browse(port=0, *, open_browser=True, hostname='localhost'):
2723 """Start the enhanced pydoc web server and open a web browser.
2724
2725 Use port '0' to start the server on an arbitrary port.
2726 Set open_browser to False to suppress opening a browser.
2727 """
2728 import webbrowser
2729 serverthread = _start_server(_url_handler, hostname, port)
2730 if serverthread.error:
2731 print(serverthread.error)
2732 return
2733 if serverthread.serving:
2734 server_help_msg = 'Server commands: [b]rowser, [q]uit'
2735 if open_browser:
2736 webbrowser.open(serverthread.url)
2737 try:
2738 print('Server ready at', serverthread.url)
2739 print(server_help_msg)
2740 while serverthread.serving:
2741 cmd = input('server> ')
2742 cmd = cmd.lower()
2743 if cmd == 'q':
2744 break
2745 elif cmd == 'b':
2746 webbrowser.open(serverthread.url)
2747 else:
2748 print(server_help_msg)
2749 except (KeyboardInterrupt, EOFError):
2750 print()
2751 finally:
2752 if serverthread.serving:
2753 serverthread.stop()
2754 print('Server stopped')
2755
2756
2757# -------------------------------------------------- command-line interface

Callers 1

cliFunction · 0.85

Calls 6

_start_serverFunction · 0.85
inputFunction · 0.70
printFunction · 0.50
openMethod · 0.45
lowerMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected