def testweb(): print "litaojun" application = None app = web.application(urls, globals()) if runtime == "SAE": application = sae.create_wsgi_app(app.wsgifunc()) else: pass return application
if not data: response.close() break if xorchar: yield ''.join(chr(ord(x) ^ xorchar) for x in data) else: yield data except httplib.HTTPException: raise app = gae_application if urlfetch else paas_application if bae: application = bae.core.wsgi.WSGIApplication(app) elif sae: application = sae.create_wsgi_app(app) else: application = app if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') import gevent import gevent.server import gevent.wsgi import gevent.monkey gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1) server = gevent.wsgi.WSGIServer(('', int(sys.argv[1])), application) logging.info('local paas_application serving at %s:%s', server.address[0],
#!/usr/bin/env python2 # coding=utf-8 import web import sys, os from url import urls default_encoding = 'utf-8' if sys.getdefaultencoding() != default_encoding: reload(sys) sys.setdefaultencoding(default_encoding) management_app = web.application(urls, locals()) # management_app.notfound = models.home.notfound if __name__ == "__main__": if 'SERVER_SOFTWARE' in os.environ: import sae sae.create_wsgi_app(management_app.wsgifunc()) else: management_app.run()
html = u'GoAgent Python Server %s \u5df2\u7ecf\u5728\u5de5\u4f5c\u4e86\uff0c\u90e8\u7f72\u65f6\u95f4 %s\n' % (__version__, ctime) start_response('200 OK', [('Content-type', 'text/plain; charset=utf-8')]) return [html.encode('utf8')] def app(environ, start_response): if urlfetch and environ['REQUEST_METHOD'] == 'POST': return gae_post(environ, start_response) elif not urlfetch: if environ['PATH_INFO'] == 'socks5': return paas_socks5(environ, start_response) else: return paas_application(environ, start_response) else: return gae_get(environ, start_response) application = app if sae is None else sae.create_wsgi_app(app) if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') import gevent, gevent.pywsgi, gevent.monkey gevent.monkey.patch_all(dns=gevent.version_info[0]>=1) def read_requestline(self): line = self.rfile.readline(8192) while line == '\r\n': line = self.rfile.readline(8192) return line gevent.pywsgi.WSGIHandler.read_requestline = read_requestline host, _, port = sys.argv[1].rpartition(':') if len(sys.argv) == 2 else ('', ':', 443) if '-ssl' in sys.argv[1:]: ssl_args = dict(certfile=os.path.splitext(__file__)[0]+'.pem') else:
) app = web.application(urls, globals()) if __name__ == "__main__": task = PeriodRetrieveTask() task.start() app.run() task.stop() print 'over' else: import os import sae root = os.path.dirname(__file__) sys.path.insert(0, os.path.join(root, 'site-packages')) application = sae.create_wsgi_app(app.wsgifunc()) # from wechat.request import RequestParser # # if __name__ == "__main__": # with open('/home/zxy/work/code/pocket-share/src/test-data/request.xml') as r: # xml = r.read() # text_req = RequestParser.parse(xml) # print text_req # from pocket.retrieve import Retrieve # # if __name__ == '__main__': # r = Retrieve() # print r.get_item_list()
'/manage/upload', 'ManageUpload', '/manage/files', 'ManageFiles', '/manage/user', 'ManageUser', '/manage/logout', 'ManageLogout', '/manage/result/(.+)', 'ManageResult') #Init Callback interface app = web.application(urls, globals()) if Setting.runtime == "SAE": import sae application = sae.create_wsgi_app(app.wsgifunc()) elif Setting.runtime == "BAE": from bae.core.wsgi import WSGIApplication application = WSGIApplication(app.wsgifunc()) else: pass #Session Regedit web.config.session_parameters['cookie_name'] = 'Garfitle_session' web.config.session_parameters['cookie_domain'] = None web.config.session_parameters['timeout'] = 86400 web.config.session_parameters['ignore_expiry'] = True web.config.session_parameters['ignore_change_ip'] = True web.config.session_parameters['secret_key'] = 'GarfieltSoJlRmFs6H2Ll' web.config.session_parameters['expired_message'] = 'Session expired'
import sae from sae.ext.shell import ShellMiddleware def urisaok(environ, start_response): status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return ["Hello, world!"] application = sae.create_wsgi_app(ShellMiddleware(urisaok, '1q2w3e4r'))
''' import logging; logging.basicConfig(level=logging.INFO) import os from transwarp import db from transwarp.web import WSGIApplication, Jinja2TemplateEngine from config import configs # init db: db.create_engine(**configs.db) # init wsgi app: wsgi = WSGIApplication(os.path.dirname(os.path.abspath(__file__))) template_engine = Jinja2TemplateEngine(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')) wsgi.template_engine = template_engine import urls wsgi.add_module(urls) if __name__ == '__main__': wsgi.run(9000) else: import sae application = sae.create_wsgi_app(wsgi.get_wsgi_application(debug=False))
# -*- coding: utf-8 -*- # autoreload import uwsgi from uwsgidecorators import timer from django.utils import autoreload @timer(3) def change_code_gracefull_reload(sig): print "heelo" if autoreload.code_changed(): print "reload it start===" uwsgi.reload() print "reload it start===" # django uwsgi import os import sys app_root = os.path.dirname(__file__) # 两者取其一 sys.path.insert(0, os.path.join(app_root, 'system')) #sys.path.insert(0, os.path.join(app_root, 'system.bundle.zip')) import django.core.handlers.wsgi import sae os.environ['DJANGO_SETTINGS_MODULE'] = 'memory.settings' application = sae.create_wsgi_app(django.core.handlers.wsgi.WSGIHandler())
template_engine.add_filter('datetime', datetime_filter) wsgi.template_engine = template_engine import urls #wsgi.add_interceptor(urls.user_interceptor) #wsgi.add_interceptor(urls.manage_interceptor) wsgi.add_module(urls) if __name__ == "__main__": # init db: db.create_engine(**configs['db']) wsgi.run() else: import sae import sae.const import os import sys root = os.path.dirname(__file__) # 两者取其一 sys.path.insert(0, os.path.join(root, 'site-packages')) db.create_engine(user=sae.const.MYSQL_USER, passwd=sae.const.MYSQL_PASS, database=sae.const.MYSQL_DB, port=int(sae.const.MYSQL_PORT), host=sae.const.MYSQL_HOST) application = sae.create_wsgi_app(wsgi.get_wsgi_application())
#-*- encoding:utf-8 -*- ''' 主文件 ''' __author__ = 'liuchang' import sae from rebot import reobt application = sae.create_wsgi_app(robot.wsgi)
class Application(tornado.web.Application): def __init__(self): self.tags = [] self.recent_posts = [] super(Application, self).__init__( handlers=routers.route, **settings) self.flash_cache() def flash_cache(self): session = db.Session() self.tags = session.query(Tag).all() self.recent_posts = session.\ query(Post.title).order_by(Post.post_time.desc())[:5] session.close() if "SERVER_SOFTWARE" in os.environ: try: import sae application = sae.create_wsgi_app(PaaSApplication()) except: from bae.core.wsgi import WSGIApplication application = WSGIApplication(PaaSApplication()) else: appilication = Application() appilication.listen(8888) tornado.ioloop.IOLoop.instance().start()
from config import db, urls import controllers.home default_encoding = 'utf-8' if sys.getdefaultencoding() != default_encoding: reload(sys) sys.setdefaultencoding(default_encoding) abspath = os.path.dirname(__file__) if abspath == "": abspath = "." sys.path.append(abspath) os.chdir(abspath) app = web.application(urls, globals(), autoreload=True) app.notfound = controllers.home.notfound # Session if web.config.get('_session') is None: web.config.session_parameters['cookie_name'] = 'foodcenter_sid' store = web.session.DBStore(db, 'hitfd_sessions') web.config._session = web.session.Session(app, store, initializer={'logged': False, 'role': 'guest'}) if __name__ == "__main__": if 'SERVER_SOFTWARE' in os.environ: import sae sae.create_wsgi_app(app.wsgifunc()) else: app.run()
if not data: response.close() break if xorchar: yield ''.join(chr(ord(x) ^ xorchar) for x in data) else: yield data except httplib.HTTPException: raise app = gae_application if urlfetch else paas_application if bae: application = bae.core.wsgi.WSGIApplication(app) elif sae: application = sae.create_wsgi_app(app) else: application = app if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') import gevent import gevent.server import gevent.wsgi import gevent.monkey gevent.monkey.patch_all(dns=gevent.version_info[0] >= 1) server = gevent.wsgi.WSGIServer(('', int(sys.argv[1])), application) logging.info('local paas_application serving at %s:%s', server.address[0], server.address[1]) server.serve_forever()
def app(environ, start_response): if urlfetch and environ['REQUEST_METHOD'] == 'POST': if environ.get('HTTP_COOKIE'): return gae_post_ex(environ, start_response) else: return gae_post(environ, start_response) elif not urlfetch: if environ['PATH_INFO'] == '/socks5': return paas_socks5(environ, start_response) else: return paas_application(environ, start_response) else: return gae_get(environ, start_response) application = app if sae is None else sae.create_wsgi_app(app) if __name__ == '__main__': logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') import gevent, gevent.pywsgi, gevent.monkey gevent.monkey.patch_all(dns=gevent.version_info[0]>=1) def read_requestline(self): line = self.rfile.readline(8192) while line == '\r\n': line = self.rfile.readline(8192) return line gevent.pywsgi.WSGIHandler.read_requestline = read_requestline host, _, port = sys.argv[1].rpartition(':') if len(sys.argv) == 2 else ('', ':', 443) if '-ssl' in sys.argv[1:]: ssl_args = dict(certfile=os.path.splitext(__file__)[0]+'.pem') else:
# -*- encoding:utf-8 -*- """ 主文件 """ __author__ = "liuchang" import sae from rebot import reobt application = sae.create_wsgi_app(robot.wsgi)