本文整理汇总了Python中fapws._evwsgi.start函数的典型用法代码示例。如果您正苦于以下问题:Python start函数的具体用法?Python start怎么用?Python start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
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()
示例2: start
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: start
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.wsgi_cb(("/returnnone", returnnone))
evwsgi.wsgi_cb(("/returnnull", returnnull))
evwsgi.wsgi_cb(("/returniternull", returniternull))
evwsgi.set_debug(0)
evwsgi.run()
示例4: start
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: start
def start():
evwsgi.start('0.0.0.0', '80')
evwsgi.set_base_module(base)
#TODO - should read /etc/cobbler/settings and provide
#any global parameters
#settings = open(fileloc, 'r')
#parse the file
#settings.close()
def sysname(environ, start_response):
#you might need to strip fully qualified domain
#if you don't have them in your cobbler install
hostname = str(environ['PATH_INFO']).split('.')[0]
fileloc = '/var/lib/cobbler/config/systems.d/' \
+ hostname + '.json'
out = {}
try:
sys = open(fileloc, 'r')
system = json.load(sys)
sys.close()
mp = system['mgmt_parameters']
km = system['ks_meta']
mp.update(km)
out['parameters'] = mp
out['classes'] = system['mgmt_classes']
out['classes'] = system['mgmt_classes']
except IOError, e:
out['parameters'] = []
out['classes'] = []
outprint = yaml.safe_dump(out, default_flow_style=True)
start_response('200 OK', [('Content-Type','text/html')])
return[outprint]
示例6: start
def start():
evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)
def hello(environ, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return ["hello world!!"]
@log.Log()
def staticlong(environ, start_response):
try:
f=open("long.txt", "rb")
except:
f=["Page not found"]
start_response('200 OK', [('Content-Type','text/html')])
return f
def embedlong(environ, start_response):
try:
c=open("long.txt", "rb").read()
except:
c=["Page not found"]
start_response('200 OK', [('Content-Type','text/html')])
return base.split_len(c,32768)
def staticshort(environ, start_response):
f=open("short.txt", "rb")
start_response('200 OK', [('Content-Type','text/html')])
return f
def testpost(environ, start_response):
print environ
print "INPUT DATA",environ["wsgi.input"].getvalue()
return ["OK. params are:%s" % (environ["fapws.params"])]
@log.Log()
@zip.Gzip()
def staticlongzipped(environ, start_response):
try:
f=open("long.txt", "rb")
except:
f=["Page not found"]
start_response('200 OK', [('Content-Type','text/html')])
return f
def iteration(environ, start_response):
start_response('200 OK', [('Content-Type','text/plain')])
yield "hello"
yield " "
yield "worlds!!"
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.set_debug(0)
evwsgi.run()
示例7: fork_main
def fork_main(child_no=1):
print 'parent:', os.getpid()
def create_shared():
return {'name': 'realtime'}
channels = create_shared()
posh.share(channels)
evwsgi.start('0.0.0.0', '8080')
evwsgi.set_base_module(base)
child = list()
for i in range(child_no):
child.append(posh.forkcall(start, i, channels))
def on_interrupt(signum, frame):
print 'terminating %i children' % len(child)
for pid in child:
print 'kill(%i)' % pid
os.kill(pid, signal.SIGINT)
signal.signal(signal.SIGINT, on_interrupt)
print 'forked %i childs' % len(child)
posh.waitall()
示例8: run_server
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()
示例9: start
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()
示例10: run
def run(self):
from blog import Blog
self.update()
self.blog = Blog(self.config)
evwsgi.start(self.config['host'], self.config['port'])
evwsgi.set_base_module(base)
self.loadWebPath()
evwsgi.run()
示例11: run_with_fapws3
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()
示例12: start_server
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()
示例13: start
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()
示例14: start
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()
示例15: start
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()