import json from channels.generic.websocket import AsyncWebsocketConsumer class EncryptedValueConsumer(AsyncWebsocketConsumer): async def connect(self): await self.accept() async def receive(self, text_data): data = json.loads(text_data) decrypted_value = data['decrypted_value'] status = self.decryption_equals_X(decrypted_value) await self.send(text_data=json.dumps({ 'status': status })) def decryption_equals_X(self, x_decrypted): return True