Creating a website for friends and me stuck on how to embed HTTP Request

Thread Starter

Samantha Groves

Joined Nov 25, 2023
151
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:

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')
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}?
 

Futurist

Joined Apr 8, 2025
721
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:

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')
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}?
If you're prepared to look at Microsoft technology then I can help. One doesn't create a website by writing code to scrutinize raw HTTP messages, modern tooling hides all that mechanical baggage. Modern web technology makes it straightforward to build sophisticated sites, with ASP.Net you can easily host the site on Windows or Linux.
 
Top