예제 #1
0
 def index_doc_set(self, doc_set_name):
     path = os.path.join(self._root_directory, doc_set_name)
     if os.path.isdir(path):
         idx = Index.open_or_create(self._index_directory)
         doc_set = DocSet(self._index_directory)
         doc_set.add_doc_set(doc_set_name)
         idx.add_field(_DOC_SET_FIELD, TEXT(stored=True))
         idxr = _DocSetIndexer(idx, doc_set_name)
         idxr.index_directory(path)
예제 #2
0
from   flask import Flask, render_template, request, redirect
from   werkzeug.wsgi import SharedDataMiddleware
from   index import Index
from   doc_set import DocSet
from   searcher import Searcher
from   jinja2 import Markup

def usage():
    print("usage: python dexter.py FILES_DIR INDEX_DIR")
    sys.exit(0)

if __name__ == '__main__':
    if len(sys.argv) == 3:
        files_root_directory = sys.argv[1]
        index_directory = sys.argv[2]
        index = Index.open_or_create(index_directory)
        app = Flask("dexter")
        app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
            '/content' : '/' # files_root_directory
        })
    else:
        usage()

@app.route("/")
def root():
    return redirect('/search')

@app.route("/search")
def search():
    global index
    query = request.args.get('q')