Hi.I am attempting to create a website for a group network , I am using Python to create the webserver.Here is my code so far:
I have some questions:Suppose I send a HTTP post request to the server with a message = {Content:Hello , From:SendingHost}.In my do_POST method the response to the post request will be 'Post requested'.I have set x = rfile.read().Does this mean that x with the argument of the above request will get the value of {Content:Hello , From:SendingHost}?
Python:
from http.server import HTTPServer, BaseHTTPRequestHandler
class NewHttp(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(bytes('','utf-8'))
def do_POST(self):
self.send_response(200)
self.send_header('Content-type', 'application/json')
self.end_headers()
self.wfile.write(bytes('Post requested','utf-8'),)
x = self.rfile.read()
y = x.decode('utf-8')