I used this all the time! When you want to quickly serve a website or a page, or even mock a quick API, you can use python to start a server:
python -m SimpleHTTPServer
This will automatically start a server on port
3000 serving files in the current directory. If you want to change the port, just append the port number at the end:
python -m SimpleHTTPServer 4000
python3 -m http.server
NOTE: python3 will start in
8000 as the default port.
Even better you can add an alias to your terminal, I use the following:
alias pserver="python3 -m http.server"
You can still adde the port like this:
Catch up with me on Twitter:@juan_allo
@2023 Juan Manuel Allo Ron. All Rights reserved