diff --git a/models.py b/models.py index 8927d69..da35416 100644 --- a/models.py +++ b/models.py @@ -60,6 +60,13 @@ class Post(db.Model): def id(self): return baseN(abs(hash(self.created)), 36)[0:6] + def curl_command( self ): + body_part = "-d \"%s\"" % self.body + headers_to_ignore = ["Host", "Content-Length", "Accept", "User-Agent" ] + headers = filter( lambda x: not x in headers_to_ignore, self.headers ) + header_part = reduce( lambda x,y: "%s -H \"%s: %s\"" % (x,y, self.headers[y]) , headers, "") + return "curl %s %s" % (body_part, header_part) + def __iter__(self): out = [] if self.form_data: diff --git a/static/style.css b/static/style.css index 9fae3bd..b54204a 100644 --- a/static/style.css +++ b/static/style.css @@ -28,4 +28,13 @@ dd { margin: 0 0 0 80px; padding: 0 0 0.5em 0; white-space: pre; +} + +.curl_command { + margin-left: 10px; + margin-right: 10px; + border-style: dashed; + border-width: 1px; + padding: 5px; + font: 11px "Courier New", Courier, mono; } \ No newline at end of file diff --git a/templates/bin.html b/templates/bin.html index f72bb33..39dbc5a 100644 --- a/templates/bin.html +++ b/templates/bin.html @@ -3,6 +3,7 @@ {% block header %}{% endblock %} {% block content %}
All POST requests to this URL are logged for you to see here, sorted newest to oldest.
+ {% for post in posts %}