-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (25 loc) · 898 Bytes
/
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
import webapp2
from scripts import scrape
from webapp2_extras import jinja2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('''
<html>
<head><title>Scrape</title></head>
<body>
<p>Insert URL</p>
<form action="/" method="post">
<div>http://<textarea name="selURL" rows="1" cols="60"></textarea></div>
<div><input type="submit" value="Scrape!"></div>
</form>
</body>
</html>''')
def post(self):
url = self.request.get('selURL')
res = scrape.scrape(url)
self._render('visualization.html', data=res)
def _render(self, template, **value):
j = jinja2.get_jinja2()
html = j.render_template(template, **value)
self.response.write(html)
app = webapp2.WSGIApplication([('/', MainHandler)], debug=True)