DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (e9d6d0965bc6)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

"""
Mozhttpd is a simple http webserver written in python, designed expressly
for use in automated testing scenarios. It is designed to both serve static
content and provide simple web services.

The server is based on python standard library modules such as
SimpleHttpServer, urlparse, etc. The ThreadingMixIn is used to
serve each request on a discrete thread.

Some existing uses of mozhttpd include Peptest_, Eideticker_, and Talos_.

.. _Peptest: https://github.com/mozilla/peptest/

.. _Eideticker: https://github.com/mozilla/eideticker/

.. _Talos: http://hg.mozilla.org/build/

The following simple example creates a basic HTTP server which serves
content from the current directory, defines a single API endpoint
`/api/resource/<resourceid>` and then serves requests indefinitely:

::

  import mozhttpd

  @mozhttpd.handlers.json_response
  def resource_get(request, objid):
      return (200, { 'id': objid,
                     'query': request.query })


  httpd = mozhttpd.MozHttpd(port=8080, docroot='.',
                            urlhandlers = [ { 'method': 'GET',
                                              'path': '/api/resources/([^/]+)/?',
                                              'function': resource_get } ])
  print "Serving '%s' at %s:%s" % (httpd.docroot, httpd.host, httpd.port)
  httpd.start(block=True)

"""
from __future__ import absolute_import

from .mozhttpd import MozHttpd, Request, RequestHandler, main
from .handlers import json_response

__all__ = ['MozHttpd', 'Request', 'RequestHandler', 'main', 'json_response']