/echo-server

Simple HTTP Echo Server

Primary LanguagePython

echo-server

This is a python http server that echoes any received request.

Example

For the following HTTP request:

$ curl --header "Favorite-Color: Purple" \
      --data "param1=value1&param2=value2"\
      http://localhost:8080/hello-mars

Server output:

$ python app.py
Echoing from http://localhost:8080
127.0.0.1 - Thu Mar 15 23:43:27 2018 - POST /hello-mars HTTP/1.1

Returned response:

POST /hello-mars HTTP/1.1
Host: localhost:3246
User-Agent: curl/7.54.0
Accept: */*
Favorite-Color: Purple
Content-Length: 27
Content-Type: application/x-www-form-urlencoded

param1=value1&param2=value2

Run

Run the application using Python 3.4+, no other dependencies are needed.

python ./app.py

Options:

  -b BIND, --bind BIND  host to bind to
  -p PORT, --port PORT  port to listen on
  -q, --quiet           do not print request body

Deployment

Docker:

docker build -t echo-server .
docker run -itp 8080:8080 echo-server

Openshift

oc new-app centos/python-35-centos7~https://github.com/flerro/echo-server --name=httpecho

Image build with s2i

s2i build https://github.com/flerro/echo-server centos/python-35-centos7 httpecho

Credits

Forked from cdfuller/echo-server