Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Webserver module for python?

Name: Anonymous 2007-07-05 14:40 ID:D+RXLJ8O

I'm currently coding some minor tools in python for which I'd like to have a more or less minimalistic web interface. Are there any simple and lightweight modules providing a http web server (or even web interfaces)? I don't really want to code this stuff myself, as these tools are just for little computer and file management purposes; the need to write a web server by my own would indeed outweigh the benefits from having a web interface under these circumstances.

Name: Anonymous 2007-07-05 14:48 ID:mMm85shv

ONE WORD, THE FORCED INDENTATION OF WEBSIGHTS

Name: Anonymous 2007-07-05 14:56 ID:Heaven

SimpleHTTPServer

Name: Anonymous 2007-07-05 15:07 ID:Heaven

Jesus. /prog/ is getting dumber every day

Name: Anonymous 2007-07-05 16:18 ID:Heaven

just use lighttpd or apache.

Name: Anonymous 2007-07-05 20:07 ID:7SLOEBJk

Do it with BBCode or don't do it AT ALL

Name: Anonymous 2007-07-05 20:08 ID:Heaven

>>6
forgot to age

Name: Anonymous 2007-07-06 7:14 ID:33rOdBwN

Apache/mod_python
lighttpd/fastcgi/flup
Django (also has a development webserver)
SimpleHTTPServer

Name: Anonymous 2007-07-06 17:32 ID:ZWhTAj8Y

You seem to misunderstand me somewhat--I don't want to run a python program on a web server, I want to develop a web interface for a python program that's run locally on the computer.
I could write the http request handler and server myself, but this would be quite tedious, so I thought there might be a pre-built solution.
SimpleHTTPServer is, well, a bit too simple, since it only serves files already in directories; I'd like to have a server which just outputs a web page that is given to it via a string (or a dictionary containing strings as the values; the keys would be the page names) and reports back the values it received via HTTP_GET or HTTP_POST (ideally in a dictionary with the keys being the variable names and values being, well, the values)

Is there something like that or do I really have to code it myself?

Name: Anonymous 2007-07-06 17:47 ID:Heaven

Use BaseHTTPServer and create a subclass of BaseHTTPRequestHandler.

Name: Anonymous 2007-07-06 18:10 ID:pU5eIVZt

>>9
I think you want to subclass SimpleHTTPRequestHandler or BaseHTTPRequestHandler and override do_GET() and do_POST().
Not sure how to extract the form values, I think CGIHTTPServer deals with that somewhere.

Name: Anonymous 2007-07-06 19:42 ID:eKkxCGM3

>>11
Nope. Just subclass BaseHTTPServer, override do_GET(self), and check self.path.
eg..

def do_GET(self):
    path = urllib.unquote(self.path)
    try:    path, query = path.split('?', 1)
    except: query = ''
    cgi_values = cgi.parse_qs(query)
    self.wfile.write('Your name is %s' % cgi_values.get('name', [None])[0])
    self.send_response(200)
    self.send_header('Content-Type', 'text/plain')
    self.end_headers()

(Note, I haven't actually tested this code; it's all from memory.)

Name: Anonymous 2009-01-14 12:38

LISP

Name: Anonymous 2010-12-06 10:03

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2013-08-04 6:11


 e
  p
   i
    c

Name: Anonymous 2013-08-04 6:11

e
  p
   i
     c

Name: Anonymous 2013-08-04 6:12

                     t 

               n             a  .. 
                 ________
                   ______/  /
           .. n .  \  \ ○ ./  /   n  .. 
                   .\  \/  /
                     .\  \/
               i      .\      a  .. 

                      s 

Don't change these.
Name: Email:
Entire Thread Thread List