[Premise]
A method to easily set up a web server in a local environment using Python's Simple HTTP Server and CGI HTTP Server. First from Simple HTTP Server. This is the minimum function, CGI does not work and only simple html can be read.
-Move to an appropriate folder (/ user / username / workspace / pypj /). -Create a new index.html. The contents are appropriate. -Execute the following command.
~/workspace/pypj 514 $python -m SimpleHTTPServer 8000
-Access from a browser with "http: // localhost: 8000".
Next is CGI HTTP Server. This is possible to run python code.
-Move to an appropriate folder (/ user / username / workspace / pypj /). -Create a new folder named "cgi-bin". -Create a new test.py in "cgi-bin". The contents are appropriate. -Give execute permission to test.py with the following command.
~/workspace/pypj/cgi-bin 518 $chmod 755 test.py
-Execute the following command from the parent folder (/ user / username / workspace / pypj /).
~/workspace/pypj 519 $python -m CGIHTTPServer 8000
-Access from a browser with "http: //localhost: 8000/cgi-bin/test.py".
Recommended Posts