Esempio n. 1
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    evhttp.set_base_module(fapws2.base)
    
    def generic(environ, start_response):
        return ["page not found"]
    
    def index(environ, start_response):
        return views.index(environ, start_response)
    
    def display(environ, start_response):
        return views.display(environ, start_response)
    def edit(environ, start_response):
	#print environ['fapws.params']
        r=views.Edit()
        return r(environ, start_response)
    def favicon(environ, start_response):
        return open("static/img/favicon.ico", "rb")
    
    evhttp.http_cb("/display/",display)
    evhttp.http_cb("/edit", edit)
    evhttp.http_cb("/new", edit)
    staticfile=fapws2.contrib.views.Staticfile("static/")
    evhttp.http_cb("/static/",staticfile)
    evhttp.http_cb('/favicon.ico',favicon),

    evhttp.http_cb("/", index)
    evhttp.gen_http_cb(generic)
        
    evhttp.event_dispatch()
Esempio n. 2
0
def start():
    evhttp.start("0.0.0.0", 5000)
    evhttp.set_base_module(base)

    def app(environ, start_response):
        environ["wsgi.multiprocess"] = False
        return wsgi_app(environ, start_response)

    evhttp.gen_http_cb(app)
    evhttp.event_dispatch()
Esempio n. 3
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    evhttp.set_base_module(base)

    static=views.Staticfile("/usr/share/moin/htdocs")
    evhttp.http_cb("/wiki", static)
    
    evhttp.gen_http_cb(moinmoinApp)
        
    evhttp.event_dispatch()
Esempio n. 4
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    evhttp.set_base_module(base)
    
    def generic(environ, start_response):
        #print "GENERIC ENV",environ
        return ["Page not found"]
    hello=mycgiapp.CGIApplication("./test.cgi")
    evhttp.http_cb("/hellocgi",hello)
    
    evhttp.gen_http_cb(generic)
        
    evhttp.event_dispatch()
Esempio n. 5
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    #print evhttp.get_timeout()
    #evhttp.set_timeout(3)
    #print evhttp.get_timeout()
    
    evhttp.set_base_module(base)
    
    def generic(environ, start_response):
        #print "GENERIC ENV",environ.env
        res=django_handler.handler(environ, start_response)
        return [res]
    
    evhttp.gen_http_cb(generic)
        
    evhttp.event_dispatch()
Esempio n. 6
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    evhttp.set_base_module(base)
    
    #@log.Log(open("access.log","a"))
    #@zip.Gzip()
    def generic(environ, start_response):
        #print "GENERIC ENV",environ
        res=django_handler.handler(environ, start_response)
        return [res]
    
    #here log will got to the standard output
    @log.Log()
    def staticfile(environ, start_response):
        #we ask the browser to store those static files in his cache for 1 hour
        res=views.Staticfile(django.__path__[0] + '/contrib/admin/media/', maxage=3600)
        return res(environ, start_response)
    
    evhttp.http_cb("/media/",staticfile)
    evhttp.gen_http_cb(generic)
        
    evhttp.event_dispatch()
Esempio n. 7
0
def start():
    evhttp.start("0.0.0.0", 8080)
    
    #print evhttp.get_timeout()
    #evhttp.set_timeout(3)
    #print evhttp.get_timeout()
    
    evhttp.set_base_module(base)
    
    def generic(environ, start_response):
        #print "GENERIC ENV",environ
        return ["Page not found"]
    
    @zip.Gzip()
    def hello(environ, start_response):
        #print "Header", environ
        if environ["PATH_INFO"]!="":
            return generic(environ, start_response)
        #print "params",environ["fapws.params"]
        #print "query",environ["QUERY_STRING"]
        #time.sleep(1)
        start_response('200 WHYNOT', [('toto',4444)])
        return ["Hello World!!"]
    
    def staticlong(environ, start_response):
        try:
            f=open("long.txt", "rb")
        except:
            f=["Page not found"]
        return f
        
    @zip.Gzip()    
    def staticlongzipped(environ, start_response):
        try:
            f=open("long.txt", "rb")
        except:
            f=["Page not found"]
        return f
        
    def staticshort(environ, start_response):
        f=open("short.txt", "rb")
        return f
    def testpost(environ, start_response):
        print "INPUT DATA",environ["wsgi.input"].getvalue()
        return ["OK. params are:%s" % (environ["fapws.params"])]
    class Test:
        def __init__(self):
            pass
        def __call__(self, environ, start_response):
            return ["Hello from Test"]
    
    evhttp.http_cb("/hello",hello)
    evhttp.http_cb("/longzipped", staticlongzipped)
    evhttp.http_cb("/long", staticlong)
    evhttp.http_cb("/short", staticshort)
    t=Test()
    evhttp.http_cb("/class", t)
    staticform=views.Staticfile("test.html")
    evhttp.http_cb("/staticform", staticform)
    evhttp.http_cb("/testpost", testpost)
    evhttp.http_cb("/",hello)
    
    evhttp.gen_http_cb(generic)
        
    evhttp.event_dispatch()