W
W
weranda2020-09-09 17:41:18
Python
weranda, 2020-09-09 17:41:18

How to make Ajax requests to Python files?

Greetings.
Please tell me the simplest example of requesting data via Ajax to a Python file. With PHP everything is done at once.

// Ajax запрос в JS
$('button').click(function(){

    $.ajax({
        type: 'POST',
        url: 'file.php',
        success: function(data) {
   			// do
    	}
    });

});


// Код в PHP
echo 'Something Data';


And how to do the same, but for a Python file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-09-09
@fox_12

import requests

url = 'http://google.com/favicon.ico'
r = requests.get(url, allow_redirects=True)
open('google.ico', 'wb').write(r.content)

D
Dr. Bacon, 2020-09-09
@bacon

The client is exactly the same, the server is completely different, there are many ways, if you give an analogue, it is most similar to laravel-level frameworks

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question