def __init__(self):
Flask.__init__(self, __name__)
# Auth Initialization
# NOTE: To invalidate all JWT's just change this secret.
self.auth = Auth(os.environ.get("JWT_SECRET"), "HS256")
# Database initialization
self.db = DB()
self.db.connect()
# Register the routes
# TODO: message rate limit 10 per 5 second
self.route("/api", methods=["GET", "POST"])(self.index)
self.route("/api/v1/myInfo", methods=["GET"])(self.my_info)
self.route("/api/v1/channel/<channel_id>/messages", methods=["POST"])(self.messages)
self.route("/api/v1/auth/login", methods=["POST"])(self.login)
self.route("/api/v1/auth/register", methods=["POST"])(self.register)
# start the ws client thread
self.ws_client = WSClient()
self.ws_client.start()
# TODO: this is temporary redis replacement. Remove it later.
self.mem_store = MemStore()
# --- HELPER METHODS ---
评论列表
文章目录