Apollo is a lightweight Python module that allows you to perform HTTP requests using only sockets. It provides a simplified way to interact with web servers. This project was developed as a demonstration for my blog post on low-level networking in Python (make sure to check it out!).
To use Apollo, follow these steps:
- Clone the repository:
git clone https://github.com/entr0pie/apollo
- Change to the project directory:
cd apollo
Apollo is very similar to the requests library. You can use it in two ways:
- Using the main functions:
from Apollo import get, post
response = get("http://example.com")
print(response.status_code) # Output: 200
response = post("http://localhost/", data={"username":"admin", "password":"12345"})
print(response.status_code) # Output: 415
response = post("http://localhost/", data={"username":"admin", "password":"12345"}, headers={"Content-Type": "application/json"})
if response.status_code == 200:
response.print()
- Building up your request by hand:
from Apollo import Request
request = Request()
request.method = "DELETE"
request.path = "/api/user/delete"
request.headers['User-Agent'] = "Secret Spy"
response = request.send()
print(response.status_code) # Output: 204
To test it somewhere, go to the server
directory and start the docker container:
cd server
docker compose up --build
This project was developed to a blog post on how to use sockets and interact with HTTP servers. That way, it isn't meant for daily use.
Also, Apollo was not built to handle keep-alive
connections. If you're requesting with it, make sure to use Connection: close
with it.
This project is under the Unlicense license.