-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
49 lines (38 loc) · 1.38 KB
/
views.py
File metadata and controls
49 lines (38 loc) · 1.38 KB
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
import glob
import os.path
import xapian
import cherrypy
class MainView:
def get_index(self):
return file("index.html")
def get_searchlog(self):
return
def get_uploaded(self):
return
def get_searchresults(self):
return
def get_file_added(self, filename):
return filename + " was successfully added<br>" + "<a href = '/'>Go on start page</a>"
def go_on_startpage(self):
return "<a href = '/'>Go on start page</a>"
def try_again(self):
return "Try again<br>" + "<a href = '/'>Go on start page</a>"
def no_file_selected(self):
html = ""
html += "<h1>No file selected.</h1>"
html += "<a href = '/'>Go on start page</a>"
return html
def get_search_results(self, matches):
html = ""
html += str(matches.size()) + " results found" + "<br>"
for m in matches:
html += "%i: %i%% docid=%i + %s\n" % (m.rank + 1, m.percent, m.docid, m.document.get_data()) + "<br>"
absPath = os.path.abspath(m.document.get_value(0))
html += '<a href="/download/?filepath=' + absPath + '">' + "Get file" + "</a><br/>"
return html + self.go_on_startpage()
def get_all_querries(self):
myfile = open("searchlog.txt", "r")
content = ""
for line in myfile:
content += line + "<br>"
return content