Fixed indentation in about example.

This commit is contained in:
Martin Mahner 2014-04-12 11:17:36 -04:00
parent c70a3e7146
commit 8ebd3d1a82

View file

@ -19,9 +19,9 @@
<h3>API</h3> <h3>API</h3>
{# Just put the script in dpaste and copy the source node #} {# Just put the script in dpaste and copy the source node #}
<div class="code"><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"> &nbsp; &nbsp;<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"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="s">'https://dpaste.de/api/'</span><span class="p">,</span></li><li id="10"> &nbsp; &nbsp; &nbsp; &nbsp;<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"> &nbsp; &nbsp;<span class="p">)</span></li><li id="12"> &nbsp; &nbsp;<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"> &nbsp; &nbsp;<span class="c"># Strip surrounding quotes (NB: response has no trailing newline)</span></li><li id="14"> &nbsp; &nbsp;<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"> &nbsp; &nbsp;<span class="n">paste_code</span><span class="p">()</span></li></ol></div> <div class="code python"><ol><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">&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="s">'https://dpaste.de/api/'</span><span class="p">,</span></li><li id="10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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">&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">)</span></li><li id="12">&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;&nbsp;&nbsp;&nbsp;<span class="c"># Strip surrounding quotes (NB: response has no trailing newline)</span></li><li id="14">&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">paste_code</span><span class="p">()</span></li></ol></div>
<br/> <br/>
<p>Save this script in <code>/usr/local/bin/dpaste</code> and <code>chmod +x ..filepath</code>.</p> <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>Usage: <code>cat foo.txt | dpaste</code></p>