dimanche 19 juin 2016

I want something to be executed through django


I know this question was asked before, but none worked for me. I have this code that I want it to be executed when a button is clicked and a message is passed

import time
from sinchsms import SinchSMS

number = '+yourmobilenumber'
message = 'I love SMS!'

client = SinchSMS(your_app_key, your_app_secret)

print("Sending '%s' to %s" % (message, number))
response = client.send_message(number, message)
message_id = response['messageId']

response = client.check_status(message_id)
while response['status'] != 'Successful':
print(response['status'])
time.sleep(1)
response = client.check_status(message_id)
print(response['status'])

Basically, what I need is to add an input in a template "HTML File", this input get passed to the message variable in the code above, same with the number. I can easily do that with instances, but how can the below get executed when a button is clicked from the form in the template?

I'm kinda newbie in Django and still finding my way

Here is the tutorial that explains how to make the python file, but execute it from the shell, not a django application.

I hope I was clear describing my problem and any help would be appreciated!


Aucun commentaire:

Enregistrer un commentaire