annotate README.txt @ 28:4509330ef8ad

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