https://github.com/veggiedefender/http-server
A minimal HTTP server implemented from scratch using Python sockets and threads
https://github.com/veggiedefender/http-server
Last synced: 8 months ago
JSON representation
A minimal HTTP server implemented from scratch using Python sockets and threads
- Host: GitHub
- URL: https://github.com/veggiedefender/http-server
- Owner: veggiedefender
- Created: 2018-05-07T00:33:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-19T13:42:58.000Z (over 7 years ago)
- Last Synced: 2025-05-07T16:16:57.769Z (8 months ago)
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# http-server
A minimal, probably-definitely-not-RFC-compliant HTTP server with an almost
flask-ish API implemented from scratch using Python sockets and threads
Don't use this for anything serious.
* There is no live demo because I'm scared to put it online.
# [API Docs](https://github.com/veggiedefender/http-server/blob/master/API.md)
Found here:
https://github.com/veggiedefender/http-server/blob/master/API.md
## Dependencies
Zero outside of the standard library, of which this project only uses `socket` and `threading`.
This means you can clone and run this right away!
**Note:** Use python 3.6 or higher, because this uses [f-strings](https://www.python.org/dev/peps/pep-0498/).
## Running
```
$ python app.py
```
## What do you mean "flask-ish?"
It looks kind of like Flask on the surface (mainly the decorator based routing)
#### Flask:
```python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
```
#### This thing:
```python
from server import Server
app = Server()
@app.route("/")
def hello(request, response):
response.body = "Hello World!"
```
## Limitations
* Does not implement all or most of HTTP
* Pretty bad at the parts of HTTP it does implement
* Super brittle, probably
* See [issues](https://github.com/veggiedefender/http-server/issues)