SourasishBasu / http-web-server-python

HTTP Web server in python

Repository from Github https://github.comSourasishBasu/http-web-server-pythonRepository from Github https://github.comSourasishBasu/http-web-server-python

HTTP Web Server

Simple web server for handling concurrent connections and serving requests written in Python with only standard libraries.

Usage

./run.sh

Start the web server listening for requests on port 4221.

Sending requests

  • GET

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

    Response

    HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 3\r\n\r\nabc
  • GET files

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

    Success Response

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

    Failed Response

    HTTP/1.1 404 Not Found\r\n\r\n
  • POST

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

    Response

    HTTP/1.1 201 Created\r\n\r\n

About

HTTP Web server in python

License:MIT License


Languages

Language:Python 98.9%Language:Shell 1.1%