CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test-api.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 # This tester listens on port 8051 for a single http request, with
4 # a URL that starts with /api/v....
5 # It exits after one request.
6 # It assumes that GeoIP is already installed on the current machine
7 # with an installation of cvmfs-server, but reads the rest from
8 # the current directory.
9 
10 from wsgiref.simple_server import make_server
11 
12 import sys
13 sys.path.append('.')
14 sys.path.append('/usr/share/cvmfs-server/webapi')
15 
16 from ctypes import cdll
17 cdll.LoadLibrary('/usr/share/cvmfs-server/webapi/GeoIP.so')
18 
19 execfile('cvmfs-api.wsgi')
20 
21 import socket
22 httpd = make_server(
23  socket.gethostname(), # The host name.
24  8051, # A port number where to wait for the request.
25  application # Our application object name, in this case a function.
26  )
27 
28 # Wait for a single request, serve it and quit.
29 httpd.handle_request()