Install Flask (and whatever else) from requirements files at provision time.
Move some files around in preparation for turning the Python parts into a legitimate package. (Tests should fail.)

The dxr folder is going to form the core of an installable package. search.py, query.py, and utils.py never change; they just get copied on build. Thus, those can live in the installed package, and the build can just be a config file and .htaccess. To serve, run dxr-serve.py --config=/my/build/dir. We can explain that in the last 2 lines output from dxr-build, much as we currently do with test-server. For WSGI, we can pass in the path to the config file in an env var.

Because this reduces repetition, it makes dev easier: we can just edit the single, installed (with python setup.py develop) version of the server, and git will pick it up—no more having to edit an untracked build artifact. More standard installation and project layout probably won't hurt our community adoption, either.

Note that the package won't encompass the entire project, as there's no nice way to make setup.py build trilite and the clang plugins (that I know of).
Strip out the CGI server, and replace it with a WSGI one.

So far, the WSGI one is just a stub, but it serves and lives in the right place.
Install the dxr module as a development link so it's importable by things like dxr-serve.py.
Make browsing work (on json-test). Serve static files. Learn the build dir from command-line flags. Ditch app singleton. Introduce WSGI file. Improve dxr-serve UI.

Wow. It's amazing how well Flask fits with DXR's design. Static files and a single template dir map exactly, and the "instance" dir represents a build folder. Like fine-toothed gears.

Details:
* Moved template and static folders to the root of the dxr package, where Flask's defaults look for them. Why be weird?
* WSGI file is entirely untested.
Invoke pip with --no-deps.

We want to make sure all our dependencies are specified in requirements.txt.
Fix some spelling errors.
Get the test server finding the right tree dirs, based on the instance dir.

This also represents a conceptual shift: a tree now does in target/trees/<tree_name>. dxr-build doesn't yet reflect this.
Load the instance-local config into Flask's config system.

Capitalize the config keys so we don't have to override any Flask stuff; Flask requires capitals.
Get the front page serving.

Flask says slashes here are platform-independent.
Make directory listings and ".html"-less source code URLs work.
Tweak a little text.
Make dxr-build complete on json-test.

* Deal with moved template directory and executables.
* Quit copying test-server.py and the template folder into the target folder.
Bring dxr-build up to speed with the changes we made in the organization of the target folder.

In other words, now the thing gets built in the way the server is expecting it to be:

target/
  config.py
  dot-htaccess (probably going away)
  trees/
    HelloWorld/
    index.html

* Factor out some jinja setup repetition in dxr-build.
* Kill the top-level "server" folder. Turn its contents from string.Template templates into jinja templates, like everything else. No more double dollar signs. This kills substitute_in_file().
Let dxr-serve take relative paths.
Make dxr-build tolerate being run over an existing target folder.

No more folder-already-exists errors
[bug 826482] Fix double slashes appearing in URLs.

These aren't tolerated by the test server anymore.

While I was at it, rewrote build_folder so it's a little (but not much) easier to follow. Took advantage of the filesizeformat Jinja filter so our file sizes are a little nicer (decimals, like the previous author wanted) and our code for dealing with them a little shorter.
Adjust makefiles after moving all the files around.
Remove the unused copy of PLY blowing around in the clang plugin.
Port the search view from CGI to Flask. Tests pass!