A simple HTTP server implementation in Python.
Report Bug
·
Request Feature
Table of Contents
httPY is a solution to the "Build Your Own HTTP Server" Challenge. It is a simple HTTP server implemented in Python that handles basic HTTP requests and responds according to specified endpoints.
- Handles incoming HTTP GET and POST requests.
- Supports various endpoints:
/
: Returns a 200 OK response./echo/{message}
: Echoes back the provided message./user-agent
: Retrieves and returns the User-Agent header from the request./files/{filename}
: Serves a file from the specified directory.- POST
/files/{filename}
: Accepts file uploads and stores them in the specified directory.
- Logs incoming requests and headers.
- Serves static files from a specified directory.
- Accepts file uploads and stores them appropriately.
- Error handling for common HTTP status codes (200, 400, 404, 500).
- Implemented using Python's
socket
module for foundational understanding.
Follow these instructions to set up httPY locally.
Ensure you have Python installed on your machine. httPY is compatible with Python 3.6 and above.
- Clone the repository
git clone https://github.com/Ashfinn/httPY.git
- Navigate to the project directory
cd httPY
- (Optional) Create and activate a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Run the server
python server.py
- Access the server
Open your browser and navigate to
http://localhost:8080
httPY provides several endpoints to interact with. Below are some examples of how to use them:
-
Root Endpoint
GET /
Response:
HTTP/1.1 200 OK
-
Echo Message
GET /echo/HelloWorld
Response:
HTTP/1.1 200 OK HelloWorld
-
User-Agent
GET /user-agent
Response:
HTTP/1.1 200 OK [Your User-Agent]
-
Serve a File
GET /files/example.txt
Response:
HTTP/1.1 200 OK [Contents of example.txt]
-
Upload a File
POST /files/upload.txt [File data]
Response:
HTTP/1.1 201 Created
For more detailed usage examples and advanced configurations, please refer to the Documentation.
This roadmap outlines the planned enhancements and features for the httPY project. The goal is to improve the functionality, security, and usability of the server.
- Implement basic HTTP GET and POST request handling
- Support multiple endpoints (
/
,/echo/{message}
,/user-agent
,/files/{filename}
) - Serve static files from a specified directory
- Accept and store file uploads
- Log incoming requests and headers
- Handle common HTTP status codes (200, 400, 404, 500)
- Add HTTPS support for secure communication
- Implement request routing capabilities
- Develop middleware functionality
- Create a web-based interface for monitoring server activity
- Integrate real-time data processing features
- Provide examples integrating with modern web frameworks
- Develop detailed use-case examples and tutorials
- Enhance documentation with comprehensive guides
- Showcase real-world applications or projects using httPY
- Create a series of tutorial videos demonstrating usage and features
- Improve code comments and documentation
- Implement extensive error handling and logging
- Write unit tests to ensure code reliability and maintainability
- Refactor code for better readability and performance
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
git clone https://github.com/Ashfinn/httPY.git
- Create your Feature Branch
git checkout -b feature/AmazingFeature
- Commit your Changes
git commit -m 'Add some AmazingFeature'
- Push to the Branch
git push origin feature/AmazingFeature
- Open a Pull Request
Feel free to open issues for bug reports or feature requests. Don't forget to give the project a star! Thanks again!
Distributed under the MIT License. See LICENSE
for more information.
Obidur Rahman - @linkedIn - obidur.shawal@gmail.com
Project Link: https://github.com/Ashfinn/httPY
- Codecrafters.io for the HTTP Server Challenge
- Python Documentation