P
P
PythonMaster2018-02-28 01:44:44
Python
PythonMaster, 2018-02-28 01:44:44

How to process and send json in pure python or bottle?

Java Scipt sending a request:
var xhr = new XMLHttpRequest();
xhr.open('GET', ' 127.0.0.1:8080 ');
xhr.send(JSON.stringify({a:1, b:2));
alert( xhr.responseText )

Please tell me how to get json in python, process it and return server status(200) and json object back to javascript.

My python code:
import http.server
http.server.test()

outputs to console:
127.0.0.1 - - [28/Feb/2018 00:28:55] "GET / HTTP/1.1" 200
without json and returns nothing
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-02-28
@dimonchik2013

https://httpbin.org/ here test if anything be the
first to get the server to return at least something, not necessarily json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question