I'm new to servers setup, I'm trying to understand - do I need Apache or smth to handle HTTP requests?
For example, I'm getting GET /api request, and I want to send a response. Can I do it without Apache? For example, just create BaseHTTPRequestHandler Python class and redefine do_GET
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/api':
some_function()
else:
another_function()
self.send_response(200)
and use some code like this:
httpd = socketserver.TCPServer(("", 8080), MyHandler)
httpd.serve_forever()
So can I do it without Apache? If yes, why do people need Apache?
PS: idk does it matter, but I want to use certificate authentication on my server.
PSS: to be clear - my company just "rents" an application, so I don't need to write app code. I need to handle some POST requests from this application by my server and then send some POST requests from my server to this application (to its server). So it is possible to do it with clear Linux and python script that I've described in the question? Or do I need to install some HTTP server (like Apache)?