<s> import json <EOL> from django . http import JsonResponse <EOL> from . utils import parse_command <EOL> from . tasks import play_sound , speak <EOL> from django . views . decorators . csrf import csrf_exempt <EOL> @ csrf_exempt <EOL> def send ( request ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> body = json . loads ( request . body ) <EOL> cmd_string = body [ '<STR_LIT>' ] or '<STR_LIT>' <EOL> if cmd_string : <EOL> parsed_cmd = parse_command ( cmd_string ) <EOL> if parsed_cmd [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> play_sound . delay ( parsed_cmd [ '<STR_LIT:args>' ] ) <EOL> res = { '<STR_LIT>' : parsed_cmd [ '<STR_LIT>' ] } <EOL> elif parsed_cmd [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> speak . delay ( parsed_cmd [ '<STR_LIT:args>' ] ) <EOL> res = { '<STR_LIT>' : parsed_cmd [ '<STR_LIT>' ] } <EOL> else : <EOL> res = { '<STR_LIT:error>' : '<STR_LIT>' + parsed_cmd [ '<STR_LIT>' ] } <EOL> else : <EOL> res = { '<STR_LIT:error>' : '<STR_LIT>' } <EOL> return JsonResponse ( res ) <EOL> else : <EOL> return JsonResponse ( { "<STR_LIT:error>" : "<STR_LIT>" } ) </s>
