~ read.

Simple HTTP Server that will give serve simple files and can emulate delay before giving response

On one of my projects i had a task where i needed to make a  simple http server that would give one xml file for our service (Trying to emulate and verify sync between two services). But besides that i had also to check that application behaves properly when you get timeout from the server on the other end. So, i've started googling and found really nice and fast solution with python SimpleHTTPServer. I found it here and modified it a little bit for my purposes with delay emulation. Here's the code :

You can save it as server.py and they simple run it on your server as: python server.py 8081 It will run this server on 8081 port ( you can change it to any free port you want) . Second value is for delay - 0 if you want server to respond right away, !=0 - set how many seconds you want server to wait before responding.

It's very fast and easy way to check this things, and i'm pretty sure i will use it in the future and maybe will modify and improve it when it will be needed. The beauty of this method is that you don't have to setup any server and launch it. All you need is installed Python ( which is already preinstalled on any Unix machine) and this file.

comments powered by Disqus
comments powered by Disqus