| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

WebApplication

Page history last edited by PBworks 15 years, 9 months ago


 

No need to struggle with configuring Apache web server if all you need is simple CGI server. Host your own:

 

Your own CGI web server on localhost

 

import CGIHTTPServer

import BaseHTTPServer

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):

    cgi_directories = ["/cgi"]

PORT = 8000

httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)

print "serving at port", PORT

httpd.serve_forever()

 

Code by effbot:

 

  • create directory for CGI server, ie. /cgihome with subdirectories ./cgi and ./server.
  • /cgihome (on Windows) should be top-level directory (and never use spaces in file/directory names). On Linux, you can place it directly in your home (~), so it might be ~/cgihome. Don't put it too deep. / in the beginning means 'root' :-)
  • save code above as file cgihttpserver.py into directory /cgihome/server
  • open commadline teminal, and run commands "cd /cgihome" and "python server/cgihttpserver.py" - server runs at localhost, port 8000
    • on Windows, you can also create icon to run it
  • put any static html page into /cgihome - it is served from http://localhost:8000/page.html
  • put any CGI program into /cgihome/cgi - it is served http://localhost:8000/cgi/scriptname.py
  • to stop server, close the commandline window
  • you can see any activities (and errors) in that terminal window
  • don't forget to close terminal when you don't need it anymore.

 

 

Introduction - Simple applications

 

 

 

Using templates

  • htmltmpl is the best from simple templating engines: has all you need, but no extra features! :-) Preinstalled on Ubuntu
  • TurboGears has excellent KID template system

 

On Windows

 

Another web server

 

  • Simple web server - cd to the the directory you want to serve, type in the one liner in the command line “python -c 'import SimpleHTTPServer; SimpleHTTPServer.test()'” and proceed to http://localhost:8000/ via browser

Comments (0)

You don't have permission to comment on this page.