Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Setup HTTP Server for Pomegranate File System

macan edited this page · 3 revisions

Setup a HTTP Server to access Pomegranate FS

Prerequisites

  1. Python (>=2.5)
  2. Cherrypy Module (>=3.1)

We have written a small HTTP server in Python with Cherrypy. This server can serve REST-like HTTP requests, such as PUT, GET, POST, and DELETE (refer to REST API). There is also a simple python client to describe how to use python httplib to access the server.

import httplib
import time

# Prepare a connection
conn = httplib.HTTPConnection("10.10.111.9:80")

# Build the header
headers = {
    "Host" : "hvfs://global",
    "Command" : "list",
    "Args" : "/",
    "Date" : time.ctime(),
    }

# Make a request and send it
conn.request("GET", "/hvfs", "", headers)

# Get the response
r1 = conn.getresponse()

# Read the response data and display them
data1 = r1.read()
print r1.status, r1.reason
print data1

By executing it, you can get the following result:

200 OK
- 100644         200000000008 a
- 100644         200000000009 b

Start it up!

$ cd test/python
$ python restserver.py
Something went wrong with that request. Please try again.