コード例 #1
0
ファイル: posit.py プロジェクト: cilsat/posit
def main():
    routes = get_routes(api)
    print("Routes\n======\n\n" + json.dumps([(url, repr(rh))
                                             for url, rh in routes]))
    app = Application(routes=routes, settings={}, generate_docs=True)
    app.listen(6060)
    tornado.ioloop.IOLoop.instance().start()
コード例 #2
0
ファイル: api_server.py プロジェクト: hugoxia/Joke
def main():
    routes = get_routes(api)
    print(routes)

    application = Application(routes=routes, settings={})

    port = config["global"]["listen_port"]
    application.listen(port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #3
0
ファイル: app.py プロジェクト: lina1/Tornado-JSON
def main():
    import cars

    routes = get_routes(cars)
    print("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    application = Application(routes=routes, settings={})

    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
コード例 #4
0
ファイル: app.py プロジェクト: githubcyc/awesome-python
def main():
    import hello
    routes = get_routes(hello)
    print("Routes\n======\n\n" +
          json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    application = Application(routes=routes, settings={})

    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
コード例 #5
0
def main():
    import api
    routes = get_routes(api)
    print("Routes\n======\n\n" +
          json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    # Create the application by passing routes and any settings
    application = Application(routes=routes, settings={}, generate_docs=True)

    # Start the application on port 8888
    application.listen(8080)
    tornado.ioloop.IOLoop.instance().start()
コード例 #6
0
ファイル: app.py プロジェクト: Tobatus/dead-guy
def main():
    import helloworld

    routes = get_routes(helloworld)
    #    routes.extend(get_routes(git))

    print ("Routes\n======\n\n" + json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    application = Application(routes=routes, settings={"token": token})

    application.listen(port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #7
0
def main():
    import helloworld

    routes = get_routes(helloworld)
    #    routes.extend(get_routes(git))

    print("Routes\n======\n\n" +
          json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    application = Application(routes=routes, settings={'token': token})

    application.listen(port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #8
0
ファイル: helloworld.py プロジェクト: JackyTao/Tornado-JSON
def main():
    # Pass the web app's package the get_routes and it will generate
    #   routes based on the submodule names and ending with lowercase
    #   request handler name (with 'handler' removed from the end of the
    #   name if it is the name).
    # [("/api/helloworld", helloworld.api.HelloWorldHandler)]
    routes = get_routes(helloworld)

    # Create the application by passing routes and any settings
    application = Application(routes=routes, settings={})

    # Start the application on port 8888
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
コード例 #9
0
ファイル: helloworld.py プロジェクト: irtiq7/tornado_pyDBlite
def main():
    # Pass the web app's package the get_routes and it will generate
    #   routes based on the submodule names and ending with lowercase
    #   request handler name (with 'handler' removed from the end of the
    #   name if it is the name).
    # [("/api/helloworld", helloworld.api.HelloWorldHandler)]
    import notes
    routes = get_routes(notes)
    print("Routes\n======\n\n" +
          json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    # Create the application by passing routes and any settings
    application = Application(routes=routes, settings={}, generate_docs=True)

    # Start the application on port 8888
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
コード例 #10
0
ファイル: main.py プロジェクト: 106-/waker
def main():
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    wkr = waker()

    import api
    routes = get_routes(api)
    routes.append(("/ws", wsstream.wsstream))
    print("Routes\n======\n\n" +
          json.dumps([(url, repr(rh)) for url, rh in routes], indent=2))
    app = Application(routes=routes, settings={})
    app.listen(8080)

    try:
        IOLoop.instance().start()
    except (KeyboardInterrupt, SystemExit):
        logging.info("Interrupted.")
def main():
    # Pass the web app's package the get_routes and it will generate
    #   routes based on the submodule names and ending with lowercase
    #   request handler name (with 'handler' removed from the end of the
    #   name if it is the name).
    # [("/api/helloworld", helloworld.api.HelloWorldHandler)]
    import ApiFiles
    routes = get_routes(ApiFiles)
    print("Routes\n======\n\n" + json.dumps(
        [(url, repr(rh)) for url, rh in routes],
        indent=2)
    )
    # Create the application by passing routes and any settings
    application = Application(routes=routes, settings={}, generate_docs=True)

    # Start the application on port 8888
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
コード例 #12
0
ファイル: main.py プロジェクト: wearetvxq/helloworld
def main():
    tornado.options.parse_command_line()
    routes = get_routes(picture)
    print("Routes\n======\n\n" + json.dumps(
        [(url, repr(rh)) for url, rh in routes],
        indent=2)
          )

    application = Application(routes=routes, settings={"debug": True, })

    application.objects = peewee_async.Manager(database)

    application.listen(8080)

    tcelery.setup_nonblocking_producer(on_ready=call_task)

    io_loop = tornado.ioloop.IOLoop.instance()

    # connect("nero_gate", host="192.168.1.5", port=27017, connect=False, io_loop=io_loop)  4
    # connect("nero_gate", host="192.168.1.5", port=27017, connect=False, io_loop=io_loop)  3
    connect("nero_gate", host="192.168.1.5", port=27017)

    io_loop.start()
コード例 #13
0
@author: Dani
"""

import tornado.ioloop
from tornado_json.routes import get_routes
from tornado_json.application import Application

from google.protobuf import timestamp_pb2
from gcloud import storage

import OFWorker

PICKLE_BUCKET = 'pickles-python'

if __name__ == '__main__':

    client = storage.Client()
    for filename in ['age_classifier.pkl', 'gender_classifier.pkl']:
        cblob = client.get_bucket(PICKLE_BUCKET).get_blob(filename)
        fp = open(filename, 'wb')
        cblob.download_to_file(fp)
        fp.close()

    routes = get_routes(OFWorker)

    application = Application(routes=routes, settings={})

    application.listen(8889)

    tornado.ioloop.IOLoop.instance().start()
コード例 #14
0
ファイル: tornadojson.py プロジェクト: bausk/metabook
def main():
    routes = get_routes(helloworld)
    application = Application(routes=routes, settings={})
    application.listen(8889)
    tornado.ioloop.IOLoop.instance().start()
コード例 #15
0
ファイル: start.py プロジェクト: 3ka5-cat/pandora
def main():
    routes = get_routes(handlers)

    application = Application(routes=routes, settings=settings, db_conn=db)
    application.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
コード例 #16
0
def main(pargs):
    global redis
    if pargs.production:
        serverConf = configobj.ConfigObj('production.ini')
    else:
        serverConf = configobj.ConfigObj('develop.ini')

    routes = [
        (r"/auth/login", FacebookGraphLoginHandler),
        (r"/", HomeHandler),
        (r"/referral/([^/]+)", ReferralHandler),
        (r"/r/([^/]+)", ReferralHandler),
        (r'/(favicon.ico)', StaticFileHandler, {
            "path": "./static/"
        }),
    ]

    for api in [game, tips, user, referral, prizes]:
        routes.extend(get_routes(api))

    if pargs.admin:
        routes.extend(get_routes(admin))
        routes.extend(get_routes(box))
        from encontact import UserDataHandler
        routes.extend([
            (r"/admin/encontact?/", UserDataHandler),
        ])

    pprint(routes, indent=4)

    mailer = Mail(aws_access_key_id=serverConf['ses']['acceskeyid'],
                  aws_secret_access_key=serverConf['ses']['secretacceskeyid'],
                  region=serverConf['ses']['region'],
                  sender=serverConf['ses']['sender'],
                  template=serverConf['ses']['templates'])

    if pargs.production:
        dyn = DynamoDBConnection.connect(
            region=serverConf['dynamo']['region'],
            access_key=serverConf['dynamo']['acceskeyid'],
            secret_key=serverConf['dynamo']['secretacceskeyid'])
        session_settings = dict(
            driver="redis",
            force_persistence=True,
            cache_driver=True,
            driver_settings=dict(
                host=serverConf['redis']['host'],
                port=int(serverConf['redis']['port']),
                db=int(serverConf['redis']['db']),
                max_connections=1024,
            ),
        )
        pool = ConnectionPool(max_connections=2,
                              host=serverConf['redis']['host'],
                              port=int(serverConf['redis']['port']),
                              db=int(serverConf['redis']['db']) + 1)

        pool2 = ConnectionPool(max_connections=2,
                               host=serverConf['redis']['host'],
                               port=int(serverConf['redis']['port']),
                               db=int(serverConf['redis']['db']))

    else:
        dyn = DynamoDBConnection.connect(region='sp-east',
                                         host='127.0.0.1',
                                         port=8000,
                                         is_secure=False,
                                         access_key='asdas',
                                         secret_key='123ads')
        session_settings = dict(
            driver="redis",
            force_persistence=True,
            cache_driver=True,
            driver_settings=dict(
                host='localhost',
                port=6379,
                db=0,
                max_connections=1024,
            ),
        )
        pool = ConnectionPool(max_connections=2,
                              host='localhost',
                              port=6379,
                              db=1)

        pool2 = ConnectionPool(max_connections=2,
                               host='localhost',
                               port=6379,
                               db=0)

    redis = Redis(connection_pool=pool)
    redis2 = Redis(connection_pool=pool2)
    engine = Engine(dynamo=dyn)
    log = logging.getLogger(__name__)
    a = logging.basicConfig(
        level=logging.INFO,
        format=
        '[ %(asctime)s ][ %(levelname)s ][ %(filename)20s:%(lineno)4s - %(funcName)20s() ] %(message)s',
        datefmt='%m-%d %H:%M',
        filename='log/nextgame.log',
        filemode='a')

    log.addHandler(a)
    settings = {
        "debug": False,
        'xsrf_cookies': False,
        'serverConfig': serverConf,
        'instance': serverConf.get('instance'),
        'engine': engine,
        'facebook_api_key': serverConf['facebook']['key'],
        'facebook_secret': serverConf['facebook']['secret'],
        'session': session_settings,
        'template_path': serverConf['ses']['templates'],
        "login_url": "/auth/login/",
        "cookie_secret": 'sopadeletrinhas123',
        "mailer": mailer,
        "production": False
    }

    if (pargs.debug):
        # log.setLevel(logging.DEBUG)
        log.debug('DEBUGGING LOG')
        settings['debug'] = True

    app = Application(routes=routes,
                      settings=settings,
                      db_conn={
                          'ping': redis,
                          'session': redis2
                      })

    if pargs.provision:
        game.models.create_schemas(engine)
        tips.models.create_schemas(engine)
        referral.models.create_schemas(engine)

    if (pargs.production):
        print('Server Production Starting')
        server = tornado.httpserver.HTTPServer(app)
        server.bind(serverConf['tornado']['port'])
        server.start(int(serverConf['tornado']['instances']))
        tornado.ioloop.IOLoop.configure(TornadoUvloop)

    else:
        print('Server Develop Starting')
        app.listen(serverConf['tornado']['port'])
        tornado.ioloop.IOLoop.configure(TornadoUvloop)

    tornado.ioloop.IOLoop.current().start()