<commit_before>{% extends "dpaste/base.html" %}

{% block title %}About dpaste.de{% endblock %}
{% block headline %}About dpaste.de{% endblock %}
{% block dpaste_nav_about %}active{% endblock %}

{% block page %}
<h3>API</h3>

<pre>#!/usr/bin/env python

import urllib
import urllib2
import sys

def paste_code():
    request = urllib2.Request(
        'http://dpaste.de/api/',
        urllib.urlencode([('content', sys.stdin.read())]),
    )
    response = urllib2.urlopen(request)
    # Strip surrounding quotes (NB: response has no trailing newline)
    print response.read()[1:-1]

if __name__ == '__main__':
    paste_code()</pre>

<p>Save this script in <code>/usr/local/bin/dpaste</code> and <code>chmod +x ..filepath</code>.</p>
<p>Usage: <code>cat foo.txt | dpaste</code></p>

<p>Or you could use <code>curl</code>:
<code>alias dpaste="curl -F 'content=&lt;-' http://dpaste.de/api/</code></p>

<hr>

<h3>Applications using the API:</h3>

<ul>
    <li><a href="https://github.com/bartTC/dpasteGUI/wiki">dpasteGUI</a>, a OS X interface</li>
    <li><a href="https://github.com/bartTC/SubDpaste">a dpaste Sublime 2 plugin</a></li>
    <li><a href="http://marmalade-repo.org/packages/dpaste_de">Marmalade</a>, a Emacs plugin</li>
</ul>


<hr/>

<h3>Imprint</h3>

<p><strong>Address:</strong></p>
<p>
    <NAME><br/>
    Lauterbacher Str. 4<br/>
    DE-18581 Putbus<br/>
    Germany
</p>

<p><strong>Jabber/E-Mail:</strong></p>
<p><a href="mailto:<EMAIL>"><EMAIL></a></p>

{% endblock %}
<commit_msg>Highlight the API example. Fixes issue #7<commit_after>{% extends "dpaste/base.html" %}

{% block title %}About dpaste.de{% endblock %}
{% block headline %}About dpaste.de{% endblock %}
{% block dpaste_nav_about %}active{% endblock %}

{% block page %}
<h3>API</h3>

{# Just put the script in dpaste and copy the source node #}
<pre class="prettyprint linenums"><ol class="linenums"><li id="1"><span class="c">#!/usr/bin/env python</span></li><li id="2">&nbsp;</li><li id="3"><span class="kn">import</span> <span class="nn">urllib</span></li><li id="4"><span class="kn">import</span> <span class="nn">urllib2</span></li><li id="5"><span class="kn">import</span> <span class="nn">sys</span></li><li id="6">&nbsp;</li><li id="7"><span class="k">def</span> <span class="nf">paste_code</span><span class="p">():</span></li><li id="8">    <span class="n">request</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">Request</span><span class="p">(</span></li><li id="9">        <span class="s">'http://dpaste.de/api/'</span><span class="p">,</span></li><li id="10">        <span class="n">urllib</span><span class="o">.</span><span class="n">urlencode</span><span class="p">([(</span><span class="s">'content'</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">read</span><span class="p">())]),</span></li><li id="11">    <span class="p">)</span></li><li id="12">    <span class="n">response</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">request</span><span class="p">)</span></li><li id="13">    <span class="c"># Strip surrounding quotes (NB: response has no trailing newline)</span></li><li id="14">    <span class="k">print</span> <span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">()[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span></li><li id="15">&nbsp;</li><li id="16"><span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span></li><li id="17">    <span class="n">paste_code</span><span class="p">()</span></li></ol></pre>

<p>Save this script in <code>/usr/local/bin/dpaste</code> and <code>chmod +x ..filepath</code>.</p>
<p>Usage: <code>cat foo.txt | dpaste</code></p>

<p>Or you could use <code>curl</code>:
<code>alias dpaste="curl -F 'content=&lt;-' http://dpaste.de/api/</code></p>

<hr>

<h3>Applications using the API:</h3>

<ul>
    <li><a href="https://github.com/bartTC/dpasteGUI/wiki">dpasteGUI</a>, a OS X interface</li>
    <li><a href="https://github.com/bartTC/SubDpaste">a dpaste Sublime 2 plugin</a></li>
    <li><a href="http://marmalade-repo.org/packages/dpaste_de">Marmalade</a>, a Emacs plugin</li>
</ul>


<hr/>

<h3>Imprint</h3>

<p><strong>Address:</strong></p>
<p>
    <NAME><br/>
    Lauterbacher Str. 4<br/>
    DE-18581 Putbus<br/>
    Germany
</p>

<p><strong>Jabber/E-Mail:</strong></p>
<p><a href="mailto:<EMAIL>"><EMAIL></a></p>

{% endblock %}

{'fraction_non_alphanumeric': 0.26482961716449305, 'fraction_numerical': 0.013041649137568364, 'mean_word_length': 5.248357424441524, 'pattern_counts': {'":': 0, '<': 273, '<?xml version=': 0, '>': 273, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4719566', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1795, 'n_words': 324}