0
|
1 FileServer
|
|
2 ===========
|
|
3
|
|
4 a simple static fileserver and directory index server in python (WSGI app)
|
|
5
|
20
|
6 About
|
|
7 -----
|
|
8
|
|
9 Often for testing you will want a static fileserver and directory
|
|
10 index as part of your WSGI stack. In addition, you may have
|
|
11 requirements to run such as part of a production WSGI
|
|
12 stack. FileServer fits these needs.
|
|
13
|
|
14 Motivation
|
|
15 ----------
|
|
16
|
|
17 I needed a directory index server a la Apache to test a PyPI clone I
|
|
18 was using. After surveying what was out there, there didn't seem
|
|
19 anything out there that was easily consumable for my purposes. So I
|
|
20 wrote one only depending on
|
|
21 `webob <http://www.webob.org/>`_ .
|
|
22
|
|
23 Contents
|
|
24 --------
|
|
25
|
|
26 ``from fileserver import *`` should give you access to all of the
|
|
27 usable components of fileserver:
|
|
28
|
|
29 * ``file_response``: return a webob response object appropriate to a
|
|
30 file name
|
|
31 * ``FileApp``: WSGI app that wraps ``file_response``
|
|
32 * ``Directory Server``: serves a directory tree and generated indices
|
|
33 * ``main``: command line entry point
|
|
34
|
|
35 ``FileApp`` and ``file_response`` are heavily borrowed from
|
|
36 http://docs.webob.org/en/latest/file-example.html though the example
|
|
37 there is more complete. I will work on making this more thorough
|
21
|
38 going forward. I also borrowed from Paste's ``StaticURLParser`` and
|
|
39 ``static.Cling``.
|
20
|
40
|
|
41 In addition there is a command line script, ``serve``, which may be
|
|
42 used to serve a directory with the
|
|
43 `wsgiref <http://docs.python.org/library/wsgiref.html>`_ server.
|
|
44
|
27
|
45 Tests
|
|
46 -----
|
|
47
|
|
48 doctests and a test runner, ``test.py``, exist in the ``tests/``
|
|
49 subdirectory of http://k0s.org/hg/FileServer . I currently use
|
|
50 ``paste.fixture.TestApp`` to mock requests and inspect responses, but
|
|
51 should probably move to
|
|
52 `WebTest <http://webtest.pythonpaste.org/en/latest/index.html>`_ .
|
|
53
|
20
|
54 Other Projects
|
|
55 --------------
|
|
56
|
|
57 While I didn't find them suitable for my use, there are other
|
|
58 standalone static fileservers available for python:
|
|
59
|
21
|
60 * `static <http://lukearno.com/projects/static/>`_
|
20
|
61
|
|
62 * `Paste <http://pythonpaste.org/modules/urlparser.html>`_ ``StaticURLParser``
|
|
63
|
|
64 * `SimpleHTTPServer <http://docs.python.org/library/simplehttpserver.html>`_
|
|
65
|
0
|
66 ----
|
|
67
|
|
68 Jeff Hammel
|
|
69
|
|
70 http://k0s.org/hg/FileServer
|