-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (25 loc) · 1 KB
/
main.py
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
#coding: utf-8
from phiDi import phidi
from phiDi import loadPage
import urllib
import webapp2
querryName = "q"
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers["Content-Type"] = "text/html"
self.response.out.write("""
<form action="/phidi">
<input type="text"name="q">
<input type="submit">
</form>
""")
class PhidiHandler(webapp2.RequestHandler):
def get(self):
self.response.headers["Content-Type"] = "text/plain"
articleName = self.request.get(urllib.unquote(querryName))
# replace whitespaces to get a valid url
articleName = articleName.replace(" ", "_")
articleName = urllib.unquote(articleName).decode("iso8859-15")
#self.response.out.write('Distance of '+ articleName + ": " + str(phidi.getDistanceTo(articleName)))
self.response.out.write(articleName)
app = webapp2.WSGIApplication([('/', MainPage), ('/phidi', PhidiHandler)], debug=True)