Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sourasishbasu/http-web-server-python

Simple web server for serving HTTP requests written in pure Python with only standard libraries
https://github.com/sourasishbasu/http-web-server-python

Last synced: about 18 hours ago
JSON representation

Simple web server for serving HTTP requests written in pure Python with only standard libraries

Awesome Lists containing this project

README

        

# HTTP Web Server
> Simple web server for handling concurrent connections and serving requests written in Python with only standard libraries.

### Usage

```bash
./run.sh
```
Start the web server listening for requests on port `4221`.

## Sending requests

- ### `GET`

```curl
$ curl -v http://localhost:4221/echo/abc
```

#### Response
```bash
HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 3\r\n\r\nabc
```

- ### `GET` files

```bash
$ curl -i http://localhost:4221/files/foo
```

#### Success Response
```bash
HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: 14\r\n\r\nHello, World!
```

#### Failed Response
```bash
HTTP/1.1 404 Not Found\r\n\r\n
```

- ### `POST`

```bash
$ curl -v --data "12345" -H "Content-Type: application/octet-stream" http://localhost:4221/files/file_123
```

#### Response
```bash
HTTP/1.1 201 Created\r\n\r\n
```