HTTPServer again

T

Tom P

Hi,
a few weeks back I posed a question about passing static data to a
request server, and thanks to some useful suggestions, got it working. I
see yesterday there is a suggestion to use a framework like Tornado
rather than base classes. However I can't figure achieve the same effect
using Tornado (BTW this is all python 2.7). The key point is how to
access the server class from within do_GET, and from the server class
instance, to access its get and set methods.

Here are some code fragments that work with HTTPServer:

class MyHandler(BaseHTTPRequestHandler):

def do_GET(self):
ss = self.server
tracks = ss.tracks
.. . .
class MyWebServer(object):
def get_params(self):
return self.global_params
def set_params(self, params):
self.global_params = params
def get_tracks(self):
return self.tracks
def __init__(self):
self.global_params = ""
self.tracks = setup_()
myServer = HTTPServer
myServer.tracks = self.get_tracks()
myServer.params = self.get_params()
self.server = myServer(('', 7878), MyHandler)
print 'started httpserver on port 7878...'
.. . . .
def main():
aServer = MyWebServer()
aServer.runIt()

if __name__ == '__main__':
main()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top