mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-19 00:09:21 +11:00
Usage update.
This commit is contained in:
parent
fa5c752ab9
commit
1d7ba5a417
1 changed files with 1 additions and 1 deletions
|
@ -25,7 +25,7 @@
|
|||
<div class="code python"><ol><li id="1"><span class="c">#!/usr/bin/env python</span></li><li id="2"> </li><li id="3"><span class="kn">from</span> <span class="nn">urllib</span> <span class="kn">import</span> <span class="n">urlencode</span></li><li id="4"><span class="kn">from</span> <span class="nn">urllib2</span> <span class="kn">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">urlopen</span></li><li id="5"><span class="kn">from</span> <span class="nn">sys</span> <span class="kn">import</span> <span class="n">stdin</span></li><li id="6"> </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">Request</span><span class="p">(</span><span class="s">'https://dpaste.de/api/'</span><span class="p">,</span> <span class="n">urlencode</span><span class="p">({</span></li><li id="9"> <span class="s">'content'</span><span class="p">:</span> <span class="n">stdin</span><span class="o">.</span><span class="n">read</span><span class="p">(),</span></li><li id="10"> <span class="s">'lexer'</span><span class="p">:</span> <span class="s">'python'</span><span class="p">,</span></li><li id="11"> <span class="s">'format'</span><span class="p">:</span> <span class="s">'url'</span><span class="p">,</span></li><li id="12"> <span class="p">}))</span></li><li id="13"> <span class="k">print</span> <span class="n">urlopen</span><span class="p">(</span><span class="n">request</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span></li><li id="14"> </li><li id="15"><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="16"> <span class="n">paste_code</span><span class="p">()</span></li></ol></div>
|
||||
<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 give it the executable bit: <code>chmod +x /usr/local/bin/dpaste</code>.</p>
|
||||
<p>Usage: <code>cat foo.txt | dpaste</code></p>
|
||||
|
||||
<p>An alternative would be to just use <code>curl</code>:
|
||||
|
|
Loading…
Reference in a new issue