Site Sponsors:
Stand-up a Basic Web Server ... in 1 Line of Code? 
There I was, starting to spin-up my AWS Server when it occurred to me: Once having resolved to use Python 3 on the back-end, why pay for the spindle-time?!

(Apache NOT Required!)

Indeed, even with a Doctor Quote front-end (written in C/C++, with a new for-discussion strawman written in Java) the basic GET / POST ops provided by Python's http.server are more than adequate for this man's B.E.S.T efforts.

Three Easy Steps


The pathway to one-line server 'nerdvanna be to:

(1) Install Python 3

(2) Create a folder to serve as the "staging area" for your web server effort, complete with a `cgi-bin` sub-directory therein. (Python uses FAST-CGI, so there are no worries there!)

(3) Open a command-line prompt, navigate to said folder, and execute the following:
python3 -m http.server 9000 --cgi --bind 127.0.0.1
(We use port 9000 for obvious reasons)

Once completed, your basic one-line server will be accepting requests at http://127.0.1:9000 on your computer. To view the same, simply open your browser & navigate to the URL.

Next Steps


The next step would be to create an index.html in the folder, refresh that browser view ... and start developing your very own 'pythonic web application.


Sharing is caring!

--Randall


p.s. We should note that PHP can also do a similar:
$ cd MyWebFolder
$ php -S 127.0.0.1:9000
You can CLICK HERE for more info.

[ add comment ] ( 28 views )   |  permalink  |  related link

<Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>