pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

20171010-simple_python_webserver.md (696B)


      1 Sometimes it can be handy to run a webserver on your local machine for testing purposes. It is not, however, always possible to install a webserver such as Apache. Never fear! Python has you covered.
      2 
      3 With one python command you can run a local webserver in which ever directory you're in. First we need to install python
      4 ```
      5 pacman -S python
      6 ```
      7 
      8 Next check the version
      9 ```
     10 python -V
     11 ```
     12 
     13 If you have `Python 2.x` then run the command
     14 ```
     15 python -m SimpleHTTPServer <port>
     16 ```
     17 
     18 If you have `Python 3.x` then run the command
     19 ```
     20 python -m http.server <port>
     21 ```
     22 
     23 If you don't specify the port then the default is `8000` for both commands.
     24 
     25 Use `Ctrl-c` to stop the webserver.
     26 
     27 That's it, simple!