Skip to content
Browse files

caved and made the form data display in a table. now also supporting …

…GET requests with query params as POST requests. kinda hackish, but it should work
  • Loading branch information...
1 parent d8b6636 commit 554dccc4ca2a814388ab690c576a46b495e27afe @progrium progrium committed Jul 5, 2009
Showing with 29 additions and 14 deletions.
  1. +18 −8 bin.py
  2. +6 −2 static/style.css
  3. +5 −4 templates/bin.html
View
26 bin.py
@@ -11,22 +11,32 @@ def get(self):
if self.request.path[-1] == '/':
self.redirect(self.request.path[:-1])
bin = self._get_bin()
- posts = bin.post_set.order('-created').fetch(50)
- request = self.request
- self.response.out.write(template.render('templates/bin.html', {'bin':bin, 'posts':posts, 'request':request}))
+ if self.request.query_string:
+ self._record_post(bin, True)
+ self.redirect('/%s' % bin.name)
+ else:
+ posts = bin.post_set.order('-created').fetch(50)
+ self.response.out.write(template.render('templates/bin.html', {'bin':bin, 'posts':posts, 'request':self.request}))
def post(self):
bin = self._get_bin()
+ self._record_post(bin)
+ if 'http://' in self.request.query_string:
+ urlfetch.fetch(url=self.request.query_string.replace('http://', 'http://hookah.webhooks.org/'),
+ payload=urllib.urlencode(self.request.POST.items()), method='POST')
+ self.redirect('/%s' % bin.name)
+
+ def _record_post(self, bin, use_get=False):
post = Post(bin=bin, remote_addr=self.request.remote_addr)
post.headers = dict(self.request.headers)
post.body = self.request.body
post.query_string = self.request.query_string
- post.form_data = [[k,v] for k,v in self.request.POST.items()]
+ if use_get:
+ data_source = self.request.GET
+ else:
+ data_source = self.request.POST
+ post.form_data = [[k,v] for k,v in data_source.items()]
post.put()
- if 'http://' in self.request.query_string:
- urlfetch.fetch(url=self.request.query_string.replace('http://', 'http://hookah.webhooks.org/'),
- payload=urllib.urlencode(self.request.POST.items()), method='POST')
- self.redirect('/%s' % bin.name)
def _get_bin(self):
name = self.request.path.replace('/', '')
View
8 static/style.css
@@ -5,8 +5,12 @@ body { font-family: Helvetica,Arial,sans-serif; font-size: smaller;}
#content { margin: 10px; }
pre { font-size: larger;}
ul { padding-left: 20px;}
+li { margin-bottom: 10px;}
#make-form { margin: 20px; text-align: center; margin-right: 80px;}
#make-form input { font-size: larger;}
+a.headers { font-size: smaller;}
+td { font-size: smaller; }
+td.key { width: 50px; font-weight: bold;}
dl {
padding: 0.5em;
@@ -16,9 +20,9 @@ dt {
clear: left;
width: 70px;
font-weight: bold;
- overflow: hidden;
+ overflow: none;
}
-dt:after { content: ":"; }
+
dd {
margin: 0 0 0 80px;
padding: 0 0 0.5em 0;
View
9 templates/bin.html
@@ -16,12 +16,13 @@
{% endfor %}
-->
</div>
- <dl>
+ <table>
{% for part in post %}
- <dt title="{{ part.0 }}">{{ part.0 }}</dt>
- <dd>{{ part.1 }}</dd>
+ <tr>
+ <td title="{{ part.0 }}" class="key">{{ part.0 }}</td>
+ <td>{{ part.1 }}</td></tr>
{% endfor %}
- </dl>
+ </table>
</li>
{% endfor %}
</ul>

0 comments on commit 554dccc

Please sign in to comment.
Something went wrong with that request. Please try again.