def main(): if config.DEBUG: m.initDb() tornado.options.parse_command_line() application = Application() application.listen(options.port) tornado.ioloop.IOLoop.instance().start()
def test_7(): #random , test id , mongo field initDb() poll = Poll.get_current_poll("telugu") print str(poll.poll_items[0].id) print json_util.dumps(poll.poll_items[0].id) print json_util.dumps(poll.poll_items[0].poll.id)
def create_app(): app = Flask(__name__) app.secret_key = 'hard to guessing13459' # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///chenhui.db' # app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True # app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True from models import initDb db = initDb() # session.permanent = True # db.init_app(app) # # init default table # with app.app_context(): # import sqlModels # # Extensions like Flask-SQLAlchemy now know what the "current" app # # is while within this block. Therefore, you can now run........ # db.create_all() # # bootstrap.init_app(app) login_manager.init_app(app) db = initDb() # register routes from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .common import common as common_blueprint app.register_blueprint(common_blueprint, url_prefix='/common') from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') from .api import api as api_1_0_blueprint app.register_blueprint(api_1_0_blueprint, url_prefix='/api') from .test import test as test_blueprint app.register_blueprint(test_blueprint, url_prefix='/test') return app
user = User.objects.get(pk = decode_signed_value(config.SERVER_SECRET , "auth_key", auth_key)) for handler in request_handlers: args = handler[0].match(request_path) func = handler[1] kwargs = {"user":user} if(post_data!=None): kwargs["post"] = post_data if(args!=None): fargs = args.groups() if(fargs): func(socket, *fargs , **kwargs) else: func(socket, **kwargs) if __name__ == "__main__": initDb() #initialize reading and file decoder #keep reading streams , auto reconnecting init_main_audio_streams() init_stream_event_handlers() server = StreamServer( ('', 8888), handle_connection) server.serve_forever()
#decode and get user auth_key = urllib.unquote(auth_key).strip() user = User.objects.get( pk=decode_signed_value(config.SERVER_SECRET, "auth_key", auth_key)) for handler in request_handlers: args = handler[0].match(request_path) func = handler[1] kwargs = {"user": user} if (post_data != None): kwargs["post"] = post_data if (args != None): fargs = args.groups() if (fargs): func(socket, *fargs, **kwargs) else: func(socket, **kwargs) if __name__ == "__main__": initDb() #initialize reading and file decoder #keep reading streams , auto reconnecting init_main_audio_streams() init_stream_event_handlers() server = StreamServer(('', 8888), handle_connection) server.serve_forever()
def test_6(): #save in db offlise for create_next_poll initDb() poll = Poll.create_next_poll("telugu", False) print poll print json_util.dumps(poll.to_son())