コード例 #1
0
ファイル: config.py プロジェクト: jonashaag/WSGITest
def run_server(app, host, port):
    from fapws import base
    from fapws._evwsgi import start, set_base_module, wsgi_cb, run
    start(host, str(port))
    set_base_module(base)
    wsgi_cb(('/', app))
    run()
コード例 #2
0
ファイル: runserver.py プロジェクト: boothale/faview
def start():
    evwsgi.start(
        os.getenv('FAVIEW_IP', '0.0.0.0'),
        os.getenv('FAVIEW_PORT', '8080'),
    )
    evwsgi.set_base_module(base)

    for local_path, real_path in MEDIA_PREFIX.iteritems():
        media_dir = ServeStatic(
            settings.MEDIA_ROOT + local_path,
            real_path,
            maxage = 2629000,
        )
        evwsgi.wsgi_cb((
            settings.MEDIA_URL + local_path,
            media_dir,
        ))

    def generic(environ, start_response):
        res = django_handler.handler(environ, start_response)
        return [res]

    evwsgi.wsgi_cb(('', generic))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #3
0
ファイル: httpd.py プロジェクト: JoshData/my2012district
def start():
	evwsgi.start('0.0.0.0', '8080') 
	evwsgi.set_base_module(base)

	def proxy(baseurl):
		def f(environ, start_response):
			try:
				import urllib2
				resp = urllib2.urlopen(baseurl + environ["PATH_INFO"] + ("?" + environ["QUERY_STRING"] if environ["QUERY_STRING"] != "" else ""))
				if resp.code == 200:
					start_response('200 OK', [('Content-Type', resp.info().gettype())])
					return [resp.read()]
			except:
				start_response('403 ERROR', [('Content-Type', 'text/plain')])
				return ['Error loading request.']
		return f

	evwsgi.wsgi_cb(('/boundaries/', proxy("http://gis.govtrack.us/boundaries/")))
	evwsgi.wsgi_cb(('/map/tiles/', proxy("http://gis.govtrack.us/map/tiles/")))
	evwsgi.wsgi_cb(('/static/rep_photos/', proxy("http://www.govtrack.us/data/photos/")))
	
	staticfile = views.Staticfile('static', maxage=2629000)
	evwsgi.wsgi_cb(('/static', staticfile))

	staticfile = views.Staticfile('your_new_district.html', maxage=2629000)
	evwsgi.wsgi_cb(('/', staticfile))

	evwsgi.set_debug(0)	   
	evwsgi.run()
コード例 #4
0
ファイル: run.py プロジェクト: tetratec/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(fapws.base)
    evwsgi.wsgi_cb(("", generic))
    evwsgi.set_debug(0)
    print "libev ABI version:%i.%i" % evwsgi.libev_version()
    evwsgi.run()
コード例 #5
0
def start():
    evwsgi.start(
        os.getenv('FAVIEW_IP', '0.0.0.0'),
        os.getenv('FAVIEW_PORT', '8080'),
    )
    evwsgi.set_base_module(base)

    for local_path, real_path in MEDIA_PREFIX.iteritems():
        media_dir = ServeStatic(
            settings.MEDIA_ROOT + local_path,
            real_path,
            maxage=2629000,
        )
        evwsgi.wsgi_cb((
            settings.MEDIA_URL + local_path,
            media_dir,
        ))

    def generic(environ, start_response):
        res = django_handler.handler(environ, start_response)
        return [res]

    evwsgi.wsgi_cb(('', generic))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #6
0
ファイル: run.py プロジェクト: yishuihanhan/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(fapws.base)
    evwsgi.wsgi_cb(("",generic))
    evwsgi.set_debug(0)    
    print "libev ABI version:%i.%i" % evwsgi.libev_version()
    evwsgi.run()
コード例 #7
0
ファイル: teste.py プロジェクト: ricardoosorio/a2z-gene
def start():
	evwsgi.start(db_link_host, str(db_link_port)) 
	evwsgi.set_base_module(base)

	evwsgi.wsgi_cb(('', application))

	evwsgi.set_debug(0)	   
	evwsgi.run()
コード例 #8
0
ファイル: server_fapws3.py プロジェクト: yaniv-aknin/labour
    def start(self):
        self.silence_spurious_logging()

        evwsgi.start(self.interface, self.port)
        evwsgi.set_base_module(base)
        evwsgi.wsgi_cb(("/", wsgi_dispatcher))
        evwsgi.set_debug(0)
        self.logger.info('%r running...' % (self,))
        evwsgi.run()
コード例 #9
0
ファイル: web.py プロジェクト: gpelipas/adobopy
def run_with_fapws3(config):
    import fapws._evwsgi as evwsgi
    from fapws import base, config

    evwsgi.start(config['host'], config['port'])
    evwsgi.set_base_module(base)
    evwsgi.wsgi_cb(('', config['request_handler']))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #10
0
def start():
    evwsgi.start(HOST, str(PORT))
    evwsgi.set_base_module(base)

    evwsgi.wsgi_cb(('/static', views.Staticfile(STATIC_PATH)))
    evwsgi.wsgi_cb(('/broadcast', broadcast))

    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #11
0
def start_server():
    evwsgi.start("0.0.0.0", "5747")
    evwsgi.set_base_module(fapws.base)
    stats_app = AnyStat()
    evwsgi.wsgi_cb(("/stats/", stats_app))
    commit = lambda: stats_app.cache.commit()
    evwsgi.add_timer(10, commit)
    #evwsgi.set_debug(1)
    evwsgi.run()
コード例 #12
0
ファイル: run.py プロジェクト: Amli/fapws3
def start():
    evwsgi.start("0.0.0.0", "5000")
    evwsgi.set_base_module(base)
    
    def app(environ, start_response):
        environ['wsgi.multiprocess'] = False
        return wsgi_app(environ, start_response)

    evwsgi.wsgi_cb(('',app))
    evwsgi.run()
コード例 #13
0
 def fapws(app,address, **options):
     import fapws._evwsgi as evwsgi
     from fapws import base
     evwsgi.start(address[0],str(address[1]))
     evwsgi.set_base_module(base)
     def app(environ, start_response):
         environ['wsgi.multiprocess'] = False
         return app(environ, start_response)
     evwsgi.wsgi_cb(('',app))
     evwsgi.run()
コード例 #14
0
ファイル: anyserver.py プロジェクト: Baffour/mturk-sentiment
 def fapws(app,address, **options):
     import fapws._evwsgi as evwsgi
     from fapws import base
     evwsgi.start(address[0],str(address[1]))
     evwsgi.set_base_module(base)
     def app(environ, start_response):
         environ['wsgi.multiprocess'] = False
         return app(environ, start_response)
     evwsgi.wsgi_cb(('',app))
     evwsgi.run()
コード例 #15
0
def start(host, port):
	"""Fapws3 WSGI application"""

	evwsgi.start(host or '127.0.0.1', port or '8000')
	evwsgi.set_base_module(fapws.base)

	evwsgi.wsgi_cb(("/api", web.application.init_memcached()))

	evwsgi.set_debug(0)
	evwsgi.run()
コード例 #16
0
ファイル: bottle.py プロジェクト: qc2105/mousetrap
 def run(self, handler):
     import fapws._evwsgi as evwsgi
     from fapws import base
     evwsgi.start(self.host, self.port)
     evwsgi.set_base_module(base)
     def app(environ, start_response):
         environ['wsgi.multiprocess'] = False
         return handler(environ, start_response)
     evwsgi.wsgi_cb(('',app))
     evwsgi.run()
コード例 #17
0
ファイル: run.py プロジェクト: yishuihanhan/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")

    evwsgi.set_base_module(base)

    hello = cgiapp.CGIApplication("./test.cgi")
    evwsgi.wsgi_cb(("/hellocgi", hello))
    testphp = cgiapp.CGIApplication("/tmp/test.php")
    evwsgi.wsgi_cb(("/testphp", testphp))

    evwsgi.run()
コード例 #18
0
ファイル: run.py プロジェクト: wuzhe/nfapws
def start():
    evwsgi.start("0.0.0.0", 8080)
    
    evwsgi.set_base_module(base)
    
    hello=cgiapp.CGIApplication("./test.cgi")
    evwsgi.wsgi_cb(("/hellocgi",hello))
    testphp=cgiapp.CGIApplication("/tmp/test.php")
    evwsgi.wsgi_cb(("/testphp",testphp))
    
        
    evwsgi.run()
コード例 #19
0
def start(name):
    print "started server at "+str(host)+":"+str(port)
    if name =="meinheld":
        from meinheld import server
        server.set_access_logger(None)
        server.set_error_logger(None)
        server.listen((host, port))
        server.run(app)
    elif name =="gevent":
        #from gevent import wsgi 
        #wsgi.WSGIServer((host, port), application=app.application, log=None).serve_forever() 
        from gevent.pywsgi import WSGIServer
        WSGIServer((host, port), app, log=None).serve_forever()
    elif name =="bjoern":
        import bjoern
        bjoern.listen(app, host, port)
        bjoern.run() 
    elif name =="eventlet":
        import eventlet
        from eventlet import wsgi
        #worker_pool = eventlet.GreenPool(2000)
        #wsgi.server(eventlet.listen(('', port)), app, custom_pool=worker_pool, log=file('/dev/null', 'w'))
        # max_size
        wsgi.server(eventlet.listen(('', port)), app, max_size=10000, log=file('/dev/null', 'w'))
    elif name =="fapws":
        import fapws._evwsgi as evwsgi
        from fapws import base
        evwsgi.start(host, str(port)) 
        evwsgi.set_base_module(base)
        evwsgi.wsgi_cb(('/', app))
        evwsgi.set_debug(0)        
        evwsgi.run()
    elif name=="uwsgi":
        print ("""Enter this command in the console
                \nsudo uwsgi --http :8000 --master --disable-logging --pythonpath /home/a/g --wsgi-file w.py --listen 2  --buffer-size 2048 --async 10000 --ugreen -p 4
            """)
        #  http://osdir.com/ml/python-wsgi-uwsgi-general/2011-02/msg00136.html
        # 
        #  Re: strange SIGPIPE: writing to a closed pipe/socket/fd on image requested from facebook -msg#00136
        """
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /1 (ip 127.0.0.1) !!!
uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 260]
IOError: write error
        """
        cmd_txt = "sudo uwsgi --http :8000 --master --harakiri 1 --harakiri-verbose --close-on-exec --disable-logging --pythonpath /home/a/todo/test --wsgi-file w2.py --listen 2  --buffer-size 2048 --async 10000 --ugreen -p 4"
        cmd(cmd_txt)
    elif name=="pycgi":
        from wsgiref.handlers import CGIHandler 
        CGIHandler().run(app)
    elif name=="pystandard":
        from wsgiref.simple_server import make_server
        make_server(host, port, app).serve_forever()
コード例 #20
0
ファイル: run.py プロジェクト: yishuihanhan/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(base)

    @trace.Trace()
    def hello(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/html')])
        return ["hello world!!"]

    evwsgi.wsgi_cb(("/hello", hello))

    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #21
0
ファイル: run.py プロジェクト: wuzhe/nfapws
def start():
    evwsgi.start("0.0.0.0", 8080)
    evwsgi.set_base_module(base)
    
    @trace.Trace()
    def hello(environ, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return ["hello world!!"]

    evwsgi.wsgi_cb(("/hello", hello))

    evwsgi.set_debug(0)    
    evwsgi.run()
コード例 #22
0
ファイル: runfapws3.py プロジェクト: mlzboy/resys
 def start(self):
     evwsgi.start(self.host, self.port)
     evwsgi.set_base_module(base)
     
     #def app(environ, start_response):
     #    environ['wsgi.multiprocess'] = False
     #    return wsgi_app(environ, start_response)
 
     evwsgi.wsgi_cb(('',self.app))
     #evwsgi.set_debug(1)#开启调试
     evwsgi.set_debug(0)        
     print "libev ABI version:%i.%i" % evwsgi.libev_version()
     evwsgi.run()
コード例 #23
0
ファイル: bottle.py プロジェクト: VShangxiao/bottle-annotated
    def run(self, handler):  # 重写 run() 函数.
        import fapws._evwsgi as evwsgi
        from fapws import base
        import sys

        evwsgi.start(self.host, self.port)
        evwsgi.set_base_module(base)

        def app(environ, start_response):  # 函数嵌套定义,特别注意.
            environ['wsgi.multiprocess'] = False
            return handler(environ, start_response)

        evwsgi.wsgi_cb(('', app))  # 调用内嵌的 app()函数
        evwsgi.run()
コード例 #24
0
    def run(self, handler):  # 重写 run() 函数.
        import fapws._evwsgi as evwsgi
        from fapws import base
        import sys

        evwsgi.start(self.host, self.port)
        evwsgi.set_base_module(base)

        def app(environ, start_response):  # 函数嵌套定义,特别注意.
            environ['wsgi.multiprocess'] = False
            return handler(environ, start_response)

        evwsgi.wsgi_cb(('', app))  # 调用内嵌的 app()函数
        evwsgi.run()
コード例 #25
0
ファイル: run.py プロジェクト: rootart/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")

    evwsgi.set_base_module(base)

    def generic(environ, start_response):
        res = django_handler.handler(environ, start_response)
        return [res]

    mediafile = views.Staticfile(django.__path__[0] + "/contrib/admin/media/", maxage=2629000)
    evwsgi.wsgi_cb(("/media/", mediafile))
    evwsgi.wsgi_cb(("", generic))

    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #26
0
 def run(self):
     try:
         # since we don't use threads, internal checks are no more required
         sys.setcheckinterval = 100000
         # fapws evwsgi.start() seems to ignore the port
         # if it's a number and requires it to be a string,
         # so we cast it here to get it to work correctly.
         host, port = self.config.bind_addr
         evwsgi.start(host, str(port))
         evwsgi.set_base_module(base)
         evwsgi.wsgi_cb(('', self.config.app))
         evwsgi.set_debug(0)
         evwsgi.run()
     except KeyboardInterrupt:
         self.stop()
コード例 #27
0
ファイル: server_adapters.py プロジェクト: valq7711/ombott
    def run(self, handler):  # pragma: no cover
        import fapws._evwsgi as evwsgi
        from fapws import base, config
        port = self.port
        if float(config.SERVER_IDENT[-2:]) > 0.4:
            # fapws3 silently changed its API in 0.5
            port = str(port)
        evwsgi.start(self.host, port)
        evwsgi.set_base_module(base)

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

        evwsgi.wsgi_cb(('', app))
        evwsgi.run()
コード例 #28
0
ファイル: fapws_publisher.py プロジェクト: rezaghanimi/core
    def serve(self, filename, conf, error):
        """Run the publisher

        In:
          -  ``filename`` -- the path to the configuration file
          - ``conf`` -- the ``ConfigObj`` object, created from the configuration file
          - ``error`` -- the function to call in case of configuration errors
        """
        host, port, conf = self._validate_conf(filename, conf, error)

        # The publisher is an events based server so call once the ``on_new_process()`` method
        self.on_new_process()

        evwsgi.start(host, str(port))
        evwsgi.set_base_module(fapws.base)
        evwsgi.wsgi_cb(self.urls)
        evwsgi.run()
コード例 #29
0
def start():
    handler = Handler(Config({
        'pool_max_runners': 5,
        'provider_appdir': os.path.join(os.path.dirname(__file__), '../../tests'),
        'router_domain': 'example.com'
    }))

    evwsgi.start("0.0.0.0", "8080")

    evwsgi.set_base_module(base)

    evwsgi.wsgi_cb(('', handler))

    evwsgi.set_debug(0)
    evwsgi.run()

    handler.free()
コード例 #30
0
ファイル: servers.py プロジェクト: 4Christopher/pyload
    def run(self, handler): # pragma: no cover
        import fapws._evwsgi as evwsgi
        from fapws import base, config

        port = self.port
        if float(config.SERVER_IDENT[-2:]) > 0.4:
            # fapws3 silently changed its API in 0.5
            port = str(port)
        evwsgi.start(self.host, port)
        evwsgi.set_base_module(base)

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

        evwsgi.wsgi_cb(('', app))
        evwsgi.run()
コード例 #31
0
ファイル: bottle.py プロジェクト: zklaus/pyphant1
    def run(self, handler):
        import fapws._evwsgi as evwsgi
        from fapws import base
        evwsgi.start(self.host, self.port)
        evwsgi.set_base_module(base)

        def app(environ, start_response):
            environ['wsgi.multiprocess'] = False
            result = handler(environ, start_response)
            if isinstance(result, basestring):
                # fapws doesn't handle strings correctly
                return iter(result)
            else:
                return result

        evwsgi.wsgi_cb(('', app))
        evwsgi.run()
コード例 #32
0
    def serve(self, filename, conf, error):
        """Run the publisher

        In:
          -  ``filename`` -- the path to the configuration file
          - ``conf`` -- the ``ConfigObj`` object, created from the configuration file
          - ``error`` -- the function to call in case of configuration errors
        """
        (host, port, conf) = self._validate_conf(filename, conf, error)

        # The publisher is an events based server so call once the ``on_new_process()`` method
        self.on_new_process()

        evwsgi.start(host, str(port))
        evwsgi.set_base_module(fapws.base)
        evwsgi.wsgi_cb(self.urls)
        evwsgi.run()
コード例 #33
0
def server_http():
    lid = LanguageIdentifier(model)
    headers = [('Content-type', 'text/javascript; charset=utf-8')]
    status = '200 OK'

    def application(environ, start_response):
        params = parse_qs(environ['QUERY_STRING'])
        text = params['q'][0]
        normalize = params['normalize'][0] == 'true'
        pred, conf = lid.classify(text, normalize=normalize)
        start_response(status, headers)
        return [pred + ' ' + str(conf)]

    evwsgi.start('127.0.0.1', '10000')
    evwsgi.set_base_module(base)
    evwsgi.wsgi_cb(('', application))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #34
0
ファイル: server.py プロジェクト: perryhau/Mole
 def run(self, handler): # pragma: no cover
     import fapws._evwsgi as evwsgi
     from fapws import base, config
     port = self.port
     if float(config.SERVER_IDENT[-2:]) > 0.4:
         # fapws3 silently changed its API in 0.5
         port = str(port)
     evwsgi.start(self.host, port)
     # fapws3 never releases the GIL. Complain upstream. I tried. No luck.
     if 'MOLE_CHILD' in os.environ and not self.quiet:
         print "WARNING: Auto-reloading does not work with Fapws3."
         print "         (Fapws3 breaks python thread support)"
     evwsgi.set_base_module(base)
     def app(environ, start_response):
         environ['wsgi.multiprocess'] = False
         return handler(environ, start_response)
     evwsgi.wsgi_cb(('', app))
     evwsgi.run()
コード例 #35
0
ファイル: server.py プロジェクト: toohamster/YouMd
    def run(self, handler):  # pragma: no cover
        import fapws._evwsgi as evwsgi
        from fapws import base, config
        port = self.port
        if float(config.SERVER_IDENT[-2:]) > 0.4:
            # fapws3 silently changed its API in 0.5
            port = str(port)
        evwsgi.start(self.host, port)
        # fapws3 never releases the GIL. Complain upstream. I tried. No luck.
        if 'MOLE_CHILD' in os.environ and not self.quiet:
            print "WARNING: Auto-reloading does not work with Fapws3."
            print "         (Fapws3 breaks python thread support)"
        evwsgi.set_base_module(base)

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

        evwsgi.wsgi_cb(('', app))
        evwsgi.run()
コード例 #36
0
def start():
    evwsgi.start("/tmp/hello_unix.sock", "unix")
    evwsgi.set_base_module(base)
    
    def hello(environ, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return ["hello world!!"]

    def iteration(environ, start_response):
        start_response('200 OK', [('Content-Type','text/plain')])
        yield "hello"
        yield " "
        yield "world!!"

    
    evwsgi.wsgi_cb(("/hello", hello))
    evwsgi.wsgi_cb(("/iterhello", iteration))

    evwsgi.set_debug(0)    
    evwsgi.run()
コード例 #37
0
ファイル: run.py プロジェクト: wuzhe/nfapws
def start():
    evwsgi.start("0.0.0.0", 8085)

    evwsgi.set_base_module(fapws.base)

    # def generic(environ, start_response):
    #    return ["page not found"]

    def index(environ, start_response):
        print "GET:", environ["fapws.uri"]
        return views.index(environ, start_response)

    def display(environ, start_response):
        print "GET:", environ["fapws.uri"]
        return views.display(environ, start_response)

    def edit(environ, start_response):
        # print environ['fapws.params']
        print "GET:", environ["fapws.uri"]
        r = views.Edit()
        return r(environ, start_response)

    favicon = fapws.contrib.views.Staticfile("static/img/favicon.ico")

    def mystatic(environ, start_response):
        print "GET:", environ["fapws.uri"]
        s = fapws.contrib.views.Staticfile("static/")
        return s(environ, start_response)

    evwsgi.wsgi_cb(("/display/", display))
    evwsgi.wsgi_cb(("/edit", edit))
    evwsgi.wsgi_cb(("/new", edit))
    evwsgi.wsgi_cb(("/static/", mystatic))
    # evwsgi.wsgi_cb(('/favicon.ico',favicon)),

    evwsgi.wsgi_cb(("/", index))
    # evhttp.gen_http_cb(generic)
    evwsgi.set_debug(0)
    print "libev ABI version:%i.%i" % evwsgi.libev_version()
    evwsgi.run()
コード例 #38
0
def start():
    evwsgi.start("0.0.0.0", "8085")

    evwsgi.set_base_module(fapws.base)

    #def generic(environ, start_response):
    #    return ["page not found"]

    def index(environ, start_response):
        print "GET:", environ['fapws.uri']
        return views.index(environ, start_response)

    def display(environ, start_response):
        print "GET:", environ['fapws.uri']
        return views.display(environ, start_response)

    def edit(environ, start_response):
        #print environ['fapws.params']
        print "GET:", environ['fapws.uri']
        r = views.Edit()
        return r(environ, start_response)

    favicon = fapws.contrib.views.Staticfile("static/img/favicon.ico")

    def mystatic(environ, start_response):
        print "GET:", environ['fapws.uri']
        s = fapws.contrib.views.Staticfile("static/")
        return s(environ, start_response)

    evwsgi.wsgi_cb(("/display/", display))
    evwsgi.wsgi_cb(("/edit", edit))
    evwsgi.wsgi_cb(("/new", edit))
    evwsgi.wsgi_cb(("/static/", mystatic))
    #evwsgi.wsgi_cb(('/favicon.ico',favicon)),

    evwsgi.wsgi_cb(("/", index))
    #evhttp.gen_http_cb(generic)
    evwsgi.set_debug(0)
    print "libev ABI version:%i.%i" % evwsgi.libev_version()
    evwsgi.run()
コード例 #39
0
ファイル: test.py プロジェクト: yishuihanhan/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(base)

    def return_file(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/html')])
        return open('big-file')

    def return_tuple(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/plain')])
        return ('Hello,', " it's me ", 'Bob!')

    def return_rfc_time(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/plain')])
        return [evwsgi.rfc1123_date(time())]

    evwsgi.wsgi_cb(("/file", return_file))
    evwsgi.wsgi_cb(("/tuple", return_tuple))
    evwsgi.wsgi_cb(("/time", return_rfc_time))

    evwsgi.run()
コード例 #40
0
ファイル: test.py プロジェクト: Amli/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(base)

    def return_file(environ, start_response):
        start_response('200 OK', [('Content-Type','text/html')])
        return open('big-file')

    def return_tuple(environ, start_response):
        start_response('200 OK', [('Content-Type','text/plain')])
        return ('Hello,', " it's me ", 'Bob!')

    def return_rfc_time(environ, start_response):
        start_response('200 OK', [('Content-Type','text/plain')])
        return [evwsgi.rfc1123_date(time())]

    evwsgi.wsgi_cb(("/file", return_file))
    evwsgi.wsgi_cb(("/tuple", return_tuple))
    evwsgi.wsgi_cb(("/time", return_rfc_time))

    evwsgi.run()
コード例 #41
0
ファイル: run.py プロジェクト: shauns/layouttests
sys.setcheckinterval = 100000  # since we don't use threads, internal checks are no more required

if options.pythonpath:
    sys.path.insert(1, options.pythonpath)

from fapws.contrib import django_handler, views, zip
import django

print "start on", (options.host, options.port)
evwsgi.start(options.host, options.port)
evwsgi.set_base_module(base)

# Favicon
favicon = views.Staticfile("static/img/favicon.ico", maxage=(3 * 60))
evwsgi.wsgi_cb(("/favicon.ico", favicon))

# Fixed assets
humans = views.Staticfile("static/robots/humans.txt")
robots = views.Staticfile("static/robots/robots.txt")
crossdomain = views.Staticfile("static/robots/crossdomain.xml")

evwsgi.wsgi_cb(("/humans.txt", humans))
evwsgi.wsgi_cb(("/robots.txt", robots))
evwsgi.wsgi_cb(("/crossdomain.xml", crossdomain))

# Static files
def general_static(environ, start_response):
    s = views.Staticfile("static/", maxage=(3 * 60))  # 3 minutes
    return s(environ, start_response)
コード例 #42
0
ファイル: test.py プロジェクト: Amli/fapws3
# -*- coding: utf-8 -*-
import fapws._evwsgi as evwsgi
from fapws import base

import time

count=0

def toto(v):
    global count
    time.sleep(v)
    count+=1
    print "defer sleep %s, counter %s, %s" % (v,count,evwsgi.defer_queue_size())

def application(environ, start_response):
    response_headers = [('Content-type', 'text/plain')]
    start_response('200 OK', response_headers)
    print "before defer", time.time()
    evwsgi.defer(toto, 0.2, False)
    #evwsgi.defer(toto, 1, True)
    print "after defer", time.time()
    return ["hello word!!"]
    
if __name__=="__main__":

    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(base)
    evwsgi.wsgi_cb(("/", application))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #43
0
ファイル: __init__.py プロジェクト: rossdylan/GIBSY
 def loadWebPath(self):
     for post in self.blog.posts:
         evwsgi.wsgi_cb(("/%s" % post.getWebPath(), post.getPostPage))
     evwsgi.wsgi_cb(("/rss", self.blog.getRSSFeed))
     evwsgi.wsgi_cb(("/css", self.blog.getPygments))
     evwsgi.wsgi_cb(("", self.blog.getIndexPage))
コード例 #44
0
    host='127.0.0.1',
    settings='settings',
)

parser.add_option('--port', dest='port')
parser.add_option('--host', dest='host')
parser.add_option('--settings', dest='settings')
parser.add_option('--pythonpath', dest='pythonpath')

options, args = parser.parse_args()
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings

sys.setcheckinterval = 100000  # since we don't use threads, internal checks are no more required

if options.pythonpath:
    sys.path.insert(0, options.pythonpath)

print 'start on', (options.host, options.port)
evwsgi.start(options.host, options.port)
evwsgi.set_base_module(base)


def generic(environ, start_response):
    res = django_handler.handler(environ, start_response)
    return [res]


evwsgi.wsgi_cb(('', generic))
evwsgi.set_debug(True)
evwsgi.run()
コード例 #45
0
ファイル: fapws3-run.py プロジェクト: jonathancua/ReproWeb
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
sys.path.insert(
    0,
    os.path.join(os.path.dirname(os.path.abspath(__file__)),
                 '3rdParty/python'))

import fapws._evwsgi as evwsgi
from fapws import base

from reproweb import app

evwsgi.start('0.0.0.0', str(app.config['SERVER_PORT']))
evwsgi.set_base_module(base)

evwsgi.wsgi_cb(('/', app))
evwsgi.set_debug(0)
evwsgi.run()
コード例 #46
0
        rec.save()
        #We defere the commit and allow the combine
        #defer(<python call back>, <argumtent>, <combined them>)
        #The argument is unique and mandatory.
        #If combined is True, then Fapws will add it in the queue if it's not yet present.
        evwsgi.defer(commit, None, True)
        #commit(True)
        return [
            template.render(**{
                "name": rec.name,
                "text": rec.text,
                "display": ndisp
            })
        ]
    else:
        return ["Name not found"]


def qsize():
    print "defer queue size:", evwsgi.defer_queue_size()


evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)
evwsgi.wsgi_cb(("/names/", names))
evwsgi.add_timer(2, qsize)
evwsgi.set_debug(0)
evwsgi.run()

con.close()
コード例 #47
0
                             wsgifunc,
                             request_queue_size=40)
         try:
             server.start()
         except KeyboardInterrupt:
             server.stop()
     elif sname == "gevent":
         from gevent.wsgi import WSGIServer
         server = WSGIServer(("0.0.0.0", port), wsgifunc, log=None)
         server.serve_forever()
     elif sname == "fapws3":
         import fapws._evwsgi as evwsgi
         from fapws import base
         evwsgi.start("0.0.0.0", str(port))
         evwsgi.set_base_module(base)
         evwsgi.wsgi_cb(("", wsgifunc))
         evwsgi.set_debug(0)
         evwsgi.run()
     else:
         usage()
 elif len(argv) == 0:
     from flup.server.fcgi import WSGIServer
     server = WSGIServer(wsgifunc,
                         bindAddress=None,
                         multiplexed=False,
                         multithreaded=False)
     server.run()
     #web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
     #app.run()
 else:
     usage()
コード例 #48
0
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(mybase)

    evwsgi.wsgi_cb(("/env", env))
    evwsgi.wsgi_cb(("/hello", hello))
    evwsgi.wsgi_cb(("/tuplehello", tuplehello))
    evwsgi.wsgi_cb(("/iterhello", iteration))
    evwsgi.wsgi_cb(("/longzipped", staticlongzipped))
    evwsgi.wsgi_cb(("/long", staticlong))
    evwsgi.wsgi_cb(("/elong", embedlong))
    evwsgi.wsgi_cb(("/short", staticshort))
    staticform = views.Staticfile("test.html")
    evwsgi.wsgi_cb(("/staticform", staticform))
    evwsgi.wsgi_cb(("/testpost", testpost))
    evwsgi.wsgi_cb(("/badscript", badscript))

    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #49
0
ファイル: fapws3_server.py プロジェクト: zofuthan/meinheld
import fapws._evwsgi as evwsgi
from fapws import base


def hello_world(environ, start_response):
    status = '200 OK'
    res = "Hello world!"
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    return [res]


evwsgi.start("0.0.0.0", "8002")
evwsgi.set_base_module(base)

evwsgi.wsgi_cb(("/", hello_world))
evwsgi.set_debug(0)
evwsgi.run()
コード例 #50
0
ファイル: _fapws.py プロジェクト: gngrwzrd/graffcity
import shared.util as util
import shared.routes as routes
import fpws

#KICK OFF FAPWS
port = 9001
options = None
args = None
usage = ""
parser = OptionParser(usage=usage)
parser.add_option("-p", "--port", dest="port", help="")
(options, args) = parser.parse_args()
port = int(getattr(options, "port", 9001))
evwsgi.start('0.0.0.0', str(port))
evwsgi.set_base_module(base)
evwsgi.wsgi_cb(('/test', fpws.test))
evwsgi.wsgi_cb((routes.login, fpws.login))
evwsgi.wsgi_cb((routes.cacheon, fpws.cacheon))
evwsgi.wsgi_cb((routes.cacheoff, fpws.cacheoff))
evwsgi.wsgi_cb((routes.register, fpws.register))
evwsgi.wsgi_cb((routes.unregister, fpws.unregister))
evwsgi.wsgi_cb((routes.changepassword, fpws.changePassword))
evwsgi.wsgi_cb((routes.getprofile, fpws.getProfileInfo))
evwsgi.wsgi_cb((routes.listtags, fpws.listTagsByUser))
evwsgi.wsgi_cb((routes.deletetag, fpws.deleteTag))
evwsgi.wsgi_cb((routes.ratetag, fpws.rateTag))
evwsgi.wsgi_cb((routes.createtag, fpws.createTag))
evwsgi.wsgi_cb((routes.search, fpws.search))
evwsgi.wsgi_cb((routes.nearby, fpws.nearby))
evwsgi.wsgi_cb((routes.arnearby, fpws.arnearby))
evwsgi.wsgi_cb((routes.latest, fpws.latest))
コード例 #51
0
ファイル: server.py プロジェクト: jerzyk/fapws3
def start():
    evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(base)
    
 
    evwsgi.wsgi_cb(("/env", env))
    evwsgi.wsgi_cb(("/hello", hello))
    evwsgi.wsgi_cb(("/iterhello", iteration))
    evwsgi.wsgi_cb(("/longzipped", staticlongzipped))
    evwsgi.wsgi_cb(("/long", staticlong))
    evwsgi.wsgi_cb(("/elong", embedlong))
    evwsgi.wsgi_cb(("/short", staticshort))
    staticform=views.Staticfile("test.html")
    evwsgi.wsgi_cb(("/staticform", staticform))
    evwsgi.wsgi_cb(("/testpost", testpost))
    evwsgi.wsgi_cb(("/badscript", badscript))

    evwsgi.set_debug(0)    
    evwsgi.run()
コード例 #52
0
'''
run_server.py
Created on Jun 24, 2012

@author: "helloIAmPau - Pasquale Boemio <boemianrapsodi[at]gmail.com>"

Welcome to Androclick server!
This is the script that fulfills your inner desires... You have only to run this!
As you can see, it uses fapws-wsgi interface that has been compiled for "littlemonkey" remote machine and has been copied into the libs folder.
If you want to run Androclick Server on another machine, you have to recompile fapws-wsgi for the destination machine. It is because it was written 
C language...
Dropping these bad things, this script creates a new server application, create a new AndroclickCore object, read the server properties
from the configuration file in the folder /etc e run everything..

Don't forget to configure properly the PYTHONPATH with the absolute path of the folders src and libs!  
'''
import fapws._evwsgi as evwsgi;
from fapws import base;
from AndroclickCore import AndroclickCore;
from AndroclickCore.AndroclickProperties import AndroclickProperties;

if __name__ == '__main__':
    ''' Where everything begins '''
    androclickServer = AndroclickCore(); # Hi! my name is Androclick Server :)  
    androclickProperties = AndroclickProperties(); # ...and I'm the smarter way to get usefull informations.
    # some things that we don't cares
    evwsgi.start(androclickProperties.getServerAddress(), str(androclickProperties.getPortNumber()));
    evwsgi.set_base_module(base);
    evwsgi.wsgi_cb(("/", androclickServer));
    evwsgi.run();
コード例 #53
0
ファイル: gateway.py プロジェクト: wooque/playground
def serv(queue):
    evwsgi.start("127.0.0.1", "8080")
    evwsgi.set_base_module(base)
    evwsgi.wsgi_cb(("/", application))
    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #54
0
def start():
    if socket_server:
        evwsgi.start("\0/org/fapws3/server", "unix")
    else:
        evwsgi.start("0.0.0.0", "8080")
    evwsgi.set_base_module(mybase)

    evwsgi.wsgi_cb(("/env", env))
    evwsgi.wsgi_cb(("/helloclass", helloclass("!!!")))
    evwsgi.wsgi_cb(("/hello", hello))
    evwsgi.wsgi_cb(("/tuplehello", tuplehello))
    evwsgi.wsgi_cb(("/iterhello", iteration))
    evwsgi.wsgi_cb(("/longzipped", staticlongzipped))
    evwsgi.wsgi_cb(("/long", staticlong))
    evwsgi.wsgi_cb(("/elong", embedlong))
    evwsgi.wsgi_cb(("/short", staticshort))
    staticform = views.Staticfile("test.html")
    evwsgi.wsgi_cb(("/staticform", staticform))
    evwsgi.wsgi_cb(("/testpost", testpost))
    evwsgi.wsgi_cb(("/badscript", badscript))

    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #55
0

def application(environ, start_response):
    if environ.get('HTTP_TESTCOOKIE_VALID', 'no') == "yes":
        response_headers = [('Content-type', 'application/x-shockwave-flash')]
        start_response('304 Not Modified', response_headers)
        return []
    response_headers = [('Content-type', 'application/x-shockwave-flash')]
    start_response('200 OK', response_headers)
    m = ming.SWFMovie()
    ac = ming.SWFAction(
        as_code.replace(
            '#TESTCOOKIE_VALUE#',
            encode_cookie(environ.get(
                settings.HTTP_TESTCOOKIE_VALUE,
                ''))).replace('#TESTCOOKIE_NAME#',
                              environ.get(settings.HTTP_TESTCOOKIE_NAME, '')))
    m.add(ac)
    return [m.as_buffer()]


if __name__ == "__main__":
    as_code = open(settings.AS_FILE).read()
    if not as_code:
        sys.exit('Check your ActionScript code')
    evwsgi.start(settings.LISTEN, settings.PORT)
    evwsgi.set_base_module(base)
    evwsgi.wsgi_cb(("/", application))
    #    evwsgi.set_debug(0)
    evwsgi.run()
コード例 #56
0
ファイル: fapws3_server.py プロジェクト: zofuthan/meinheld
from flask import Flask, render_template
import fapws._evwsgi as evwsgi
from fapws import base

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('hello.html')

evwsgi.start("0.0.0.0", "8002")
evwsgi.set_base_module(base)
    
evwsgi.wsgi_cb(("/", app))
evwsgi.set_debug(0)    
evwsgi.run()