Hi,
In the code below I am validating page requests and then want to cause a simple send of the known page to the browser. What class and method should I use?

Thanks Steve
----------------------------------------------------------------------------
import os, sys
from twisted.web import http, static, server, resource
from twisted.internet.protocol import Factory
from twisted.internet import reactor

class RequestHandler(http.Request):
   pageHandlers = {
       'index.html': 'def',
       'main.html': 'def',
       #'/posthandler': handlePost,
   }
   def process(self):
       filename = os.path.basename(self.path)
       print "[process] request = " + self.path

       if self.pageHandlers.has_key(filename):
           handler = self.pageHandlers[filename]
           if handler == 'def':
### What do I call here to simply get the page sent to the browser??? ####
           else:
               handler(self, filename)
       else:
           self.setHeader('Content-Type', 'text/html')
           self.setResponseCode(http.NOT_FOUND)
           self.write("<h1>Not Found</h1>Sorry, no such page.")
           self.finish()

class ServerProtocol(http.HTTPChannel):
   requestFactory = RequestHandler

os.chdir('D:\\html')

factory = http.HTTPFactory()
factory.protocol = ServerProtocol
reactor.listenTCP(80, factory)
reactor.run()

_________________________________________________________________
Find the coolest online games @ http://xtramsn.co.nz/gaming


_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to