Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to debug a XML-RPC application, which sends XML replies over HTTP. I have a sample XML reply (i.e. data from the server, sent to the client that isn't working), I'd like to debug my application. Ideally I'd like a simple HTTP server that will serve one file in reply to all requests. Someone requests /? Send them this file. Someone makes a post to /server/page.php with a certain cookie? Just send them this file. I don't care about multithreading, or security. I will only need to use this for a few hours to debug. I have root on the machine.

i.e. I'm hoping there's something as easy to use as this:

simple_http_server -p 12445 -f my_test_file

I'm aware of python's SimpleHTTPServer module, but I'm not sure how to make it work in this case.

share|improve this question
up vote 4 down vote accepted

If you have inetd installed, just create a script like (I made a mistake, the script is not needed)

cat $1

then add the line to inetd.conf

http stream  tcp   nowait root  /bin/cat cat /some/other/dir/file.txt

With Python just extend the BaseHTTPServer.BaseHTTPRequestHandler class and define a do_GET method, then run as described in the documentation, e.g.

import BaseHTTPServer
class HTTPHandlerOne(BaseHTTPServer.BaseHTTPRequestHandler):
  def do_GET(self): self.wfile.write("test\r\n")

def run(server_class=BaseHTTPServer.HTTPServer,
    server_address = ('', 8000)
    httpd = server_class(server_address, handler_class)

share|improve this answer
thanks for the python example – Julius Musseau Oct 5 '15 at 21:41

You could add a mod_rewrite rule to an apache vhost that would rewrite all requests back to the file you want to serve.

<VirtualHost *:80>
ServerName onefilevhost.local

RewriteEngine On
RewriteRule ^/(.*)? http://onefilevhost.local/serve/this/file.txt
share|improve this answer

You can do that with Sinatra quite easy. Install sinatra doing gem install sinatra and create a test_page.rb file like this:

require 'sinatra'

get '/*' do'/server/page.php')

If you don't have $RUBYOPT=rubygems on your shell, add require 'rubygems' at the beginning.

You can run it with ruby test_page.rb. It will listen on port 4567 by default.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.