from django.shortcuts import render

# Create your views here.

from random import randint
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json


@csrf_exempt
def index(request):
    # Get Zip code from request
    print("Request=")
    print(request)
    print("Request body=")
    print(request.body)

    # Create return message
    thanks_array=["No problem!", "No problem at all!", "No worries, I'm here to help!", "You're welcome!", "You're very welcome!", 
                  "My pleasure!", ":kappa:", "It is my will to serve you, my lord.", "No probs.", "As you wish, my master.",
                  ":+1:", ":thumbsup_all:", ":heavy_check_mark:", "Just doing my job."]
    thanks_string = thanks_array[randint(0,13)]
    print("Creating payload...")
    payload = { 'response_type': "in_channel", 'text': thanks_string }
    print("payload=")
    print(payload)
    print("dumps(payload)=")
    print(json.dumps(payload))

    print("Returning payload...")
    return HttpResponse(json.dumps(payload), content_type='application/json')

