0

I have this python code:

from twilio.rest import Client

account_sid = "myID"
auth_token = "myAuth"

client = Client(account_sid, auth_token)

client.api.account.messages.create(
to="+num1",
from_="num2",
body="Hello there!")

and when I execute it on the command line python file.py everything works fine,(aka a text is sent to my phone) but I want to execute this code from a javascript file and I am doing this:

$.ajax({
  type: "GET",
  url: "file.py",
}).done(function( o ) {
   console.error("WOW")
});

but the python is not being executed although I do see the console error. I'm not too sure whats going on, I'm wondering if this needs to be changed to a POST request, but that simply gives me a 404 not found error.

1 Answer 1

1

I don't think we can give a python filename as url value. AJAX will send a request to the server and in order to handle that request we will need a server side scripting language. Below link explains how to handle AJAX request in Django.

How do I integrate Ajax with Django applications?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.