MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / browse

Function browse

tools/python-3.11.9-amd64/Lib/pydoc.py:2770–2802  ·  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

2768
2769
2770def browse(port=0, *, open_browser=True, hostname='localhost'):
2771 """Start the enhanced pydoc web server and open a web browser.
2772
2773 Use port '0' to start the server on an arbitrary port.
2774 Set open_browser to False to suppress opening a browser.
2775 """
2776 import webbrowser
2777 serverthread = _start_server(_url_handler, hostname, port)
2778 if serverthread.error:
2779 print(serverthread.error)
2780 return
2781 if serverthread.serving:
2782 server_help_msg = 'Server commands: [b]rowser, [q]uit'
2783 if open_browser:
2784 webbrowser.open(serverthread.url)
2785 try:
2786 print('Server ready at', serverthread.url)
2787 print(server_help_msg)
2788 while serverthread.serving:
2789 cmd = input('server> ')
2790 cmd = cmd.lower()
2791 if cmd == 'q':
2792 break
2793 elif cmd == 'b':
2794 webbrowser.open(serverthread.url)
2795 else:
2796 print(server_help_msg)
2797 except (KeyboardInterrupt, EOFError):
2798 print()
2799 finally:
2800 if serverthread.serving:
2801 serverthread.stop()
2802 print('Server stopped')
2803
2804
2805# -------------------------------------------------- command-line interface

Callers 1

cliFunction · 0.85

Calls 6

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

Tested by

no test coverage detected