Search code examples
pythonpydoc

Running pydocs in a external server - Python


I have a project which I would like to have it's documentation on a external server. I know I do pydoc -p 5000 I will have my documentation on http://localhost:5000/. However I'm planning to host that documentation on a EC2 instance, as an external server everyone can access. Let's say the IP address of the machine is 10.10.10.10, and it's totally configurable to be access externally. How can I have pydoc to run my server externally?


Solution

  • As the docs state:

    Specifying a -w flag before the argument will cause HTML documentation to be written out to a file in the current directory, instead of displaying text on the console.

    Therefore, use the -w flag to write the documentation to files, which you can then copy to your server and have it served as static files. For example, the command pydoc -w somelib would write a file somelib.html which contained the documentation for somelib. Copy that to the root of your server and it would be available at http://10.10.10.10/somelib.html (assuming your server is configured correctly).