I was working on the documentation for some of my open source libraries this week (@snowfrog/option and @snowfrog/result, check them out) and found myself wanting to quickly serve the documentation websites locally.
I'm using TypeDoc, which parses your TypeScript code and generates an entire API documentation website pretty much automatically. But seeing as it's an actual website and not just a simple static html file, you can't just open index.html in your browser and have the whole thing work. You need to actually serve the site with a web server.
Now I know there are different options out there for doing that, some are even integrated with your favourite IDEs and code editors. But this week I have found a way to do this that is amazingly simple and works from the command line; so it works no matter what you're doing and which software you are using in the moment.
All you need is to have Python 3 installed on your machine - you probably have it, if not here's a download link. Then, simply run the following command from the folder where your index.html is located:
python -m http.server 4200
The 4200
here is the port number, you can make that whatever you want. For more information, here is a link the documentation for this Python http server module.
Comments