def form_valid(self, form): name = form.cleaned_data['name'] username = form.cleaned_data['username'] email = form.cleaned_data['email'] chat = ChatApi() chat.login(name, username, email) self.request.session['token'] = chat.token data = {'token': chat.token} return HttpResponse(json.dumps(data), mimetype="application/json")
def update(self, token, **kwargs): chat = ChatApi(token=token) chat.update() return HttpResponse(json.dumps([message.json() for message in chat.messages]), mimetype="application/json")
def send(self, token, **kwargs): chat = ChatApi(token=token) chat.send(kwargs["message"]) return HttpResponse(json.dumps({'ok': 'ok'}), mimetype="application/json")