import DQXUtils


def application(environ, start_response):
    #For the root we do a relative redirect to index.html, hoping the app has one
    if environ['PATH_INFO'] == '/':
        start_response('301 Moved Permanently', [('Location', 'index.html'),])
        return

    DQXUtils.LogServer('404:' + environ['PATH_INFO'])
    start_response('404 Not Found', [])
    try:
        with open('static/404.html') as page:
            yield page.read()
    except IOError:
        yield '404 Page Not Found'
    return
@@ -9,16 +9,33 @@
 QXUtils%0A
+import DQXDbTools
 %0A%0Adef ap
@@ -283,16 +283,570 @@
 return%0A%0A
+    with DQXDbTools.DBCursor() as cur:%0A        cur.execute('select id from datasetindex')%0A        datasets = %5Bd%5B0%5D for d in cur.fetchall()%5D%0A%0A    #Redirect to specific dataset%0A    path = environ%5B'PATH_INFO'%5D.split('/')%0A    if len(path) %3E= 2 and path%5B-2%5D in datasets:%0A        start_response('301 Moved Permanently', %5B('Location', '../index.html?dataset='+path%5B-2%5D),%5D)%0A        return%0A    if path%5B-1%5D in datasets:%0A        start_response('301 Moved Permanently', %5B('Location', '../index.html?dataset='+path%5B-1%5D),%5D)%0A        return%0A%0A    #Everything else is 404%0A
     DQXU

Allow URLS to have dataset names in