forked from GithubBackups/healthchecks
Update usage examples, add Ruby. Fixes #158
This commit is contained in:
parent
61191d1cb9
commit
6bc3a445db
@ -31,12 +31,13 @@ class Command(BaseCommand):
|
|||||||
_process("bash_wget", lexers.BashLexer())
|
_process("bash_wget", lexers.BashLexer())
|
||||||
_process("browser", lexers.JavascriptLexer())
|
_process("browser", lexers.JavascriptLexer())
|
||||||
_process("crontab", lexers.BashLexer())
|
_process("crontab", lexers.BashLexer())
|
||||||
|
_process("node", lexers.JavascriptLexer())
|
||||||
_process("python_urllib2", lexers.PythonLexer())
|
_process("python_urllib2", lexers.PythonLexer())
|
||||||
_process("python_requests", lexers.PythonLexer())
|
_process("python_requests", lexers.PythonLexer())
|
||||||
_process("php", lexers.PhpLexer())
|
_process("php", lexers.PhpLexer())
|
||||||
_process("powershell", lexers.shell.PowerShellLexer())
|
_process("powershell", lexers.shell.PowerShellLexer())
|
||||||
_process("powershell_inline", lexers.shell.BashLexer())
|
_process("powershell_inline", lexers.shell.BashLexer())
|
||||||
_process("node", lexers.JavascriptLexer())
|
_process("ruby", lexers.RubyLexer())
|
||||||
|
|
||||||
# API examples
|
# API examples
|
||||||
_process("list_checks_request", lexers.BashLexer())
|
_process("list_checks_request", lexers.BashLexer())
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<li><a href="{% url 'hc-docs' %}#crontab">Crontab</a></li>
|
<li><a href="{% url 'hc-docs' %}#crontab">Crontab</a></li>
|
||||||
<li><a href="{% url 'hc-docs' %}#bash">Bash</a></li>
|
<li><a href="{% url 'hc-docs' %}#bash">Bash</a></li>
|
||||||
<li><a href="{% url 'hc-docs' %}#python">Python</a></li>
|
<li><a href="{% url 'hc-docs' %}#python">Python</a></li>
|
||||||
|
<li><a href="{% url 'hc-docs' %}#ruby">Ruby</a></li>
|
||||||
<li><a href="{% url 'hc-docs' %}#node">Node</a></li>
|
<li><a href="{% url 'hc-docs' %}#node">Node</a></li>
|
||||||
<li><a href="{% url 'hc-docs' %}#php">PHP</a></li>
|
<li><a href="{% url 'hc-docs' %}#php">PHP</a></li>
|
||||||
<li><a href="{% url 'hc-docs' %}#browser">Browser</a></li>
|
<li><a href="{% url 'hc-docs' %}#browser">Browser</a></li>
|
||||||
|
@ -115,9 +115,24 @@ thing: they fire off a HTTP GET method.</p>
|
|||||||
|
|
||||||
<a name="python"></a>
|
<a name="python"></a>
|
||||||
<h3>Python</h3>
|
<h3>Python</h3>
|
||||||
{% include "front/snippets/python_urllib2.html" %}
|
|
||||||
|
<p>
|
||||||
|
If you are already using the
|
||||||
|
<a href="http://docs.python-requests.org/en/master/">requests</a> library,
|
||||||
|
it's convenient to also use it here:
|
||||||
|
</p>
|
||||||
{% include "front/snippets/python_requests.html" %}
|
{% include "front/snippets/python_requests.html" %}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Otherwise, you can use the <code>urllib</code> standard module.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% include "front/snippets/python_urllib2.html" %}
|
||||||
|
|
||||||
|
<a name="ruby"></a>
|
||||||
|
<h3>Ruby</h3>
|
||||||
|
{% include "front/snippets/ruby.html" %}
|
||||||
|
|
||||||
<a name="node"></a>
|
<a name="node"></a>
|
||||||
<h3>Node</h3>
|
<h3>Node</h3>
|
||||||
{% include "front/snippets/node.html" %}
|
{% include "front/snippets/node.html" %}
|
||||||
|
@ -286,6 +286,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#python" data-toggle="tab">Python</a>
|
<a href="#python" data-toggle="tab">Python</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#ruby" data-toggle="tab">Ruby</a>
|
||||||
|
</li>
|
||||||
<li class="hidden-xs">
|
<li class="hidden-xs">
|
||||||
<a href="#node" data-toggle="tab">Node.js</a>
|
<a href="#node" data-toggle="tab">Node.js</a>
|
||||||
</li>
|
</li>
|
||||||
@ -318,6 +321,9 @@
|
|||||||
{% include "front/snippets/python_urllib2.html" %}
|
{% include "front/snippets/python_urllib2.html" %}
|
||||||
{% include "front/snippets/python_requests.html" %}
|
{% include "front/snippets/python_requests.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="ruby">
|
||||||
|
{% include "front/snippets/ruby.html" %}
|
||||||
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="node">
|
<div role="tabpanel" class="tab-pane" id="node">
|
||||||
{% include "front/snippets/node.html" %}
|
{% include "front/snippets/node.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<div class="highlight"><pre><span></span><span class="c1"># using urllib2:</span>
|
<div class="highlight"><pre><span></span><span class="c1"># urllib with python 3.x:</span>
|
||||||
<span class="kn">import</span> <span class="nn">urllib2</span>
|
<span class="kn">import</span> <span class="nn">urllib.request</span>
|
||||||
<span class="n">urllib2</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s2">"{{ ping_url }}"</span><span class="p">)</span>
|
<span class="n">urllib</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s2">"{{ ping_url }}"</span><span class="p">)</span>
|
||||||
|
|
||||||
|
<span class="c1"># urllib with python 2.x:</span>
|
||||||
|
<span class="kn">import</span> <span class="nn">urllib</span>
|
||||||
|
<span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="s2">"{{ ping_url }}"</span><span class="p">)</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
# using urllib2:
|
# urllib with python 3.x:
|
||||||
import urllib2
|
import urllib.request
|
||||||
urllib2.urlopen("PING_URL")
|
urllib.request.urlopen("PING_URL")
|
||||||
|
|
||||||
|
# urllib with python 2.x:
|
||||||
|
import urllib
|
||||||
|
urllib.urlopen("PING_URL")
|
||||||
|
5
templates/front/snippets/ruby.html
Normal file
5
templates/front/snippets/ruby.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<div class="highlight"><pre><span></span><span class="nb">require</span> <span class="s1">'net/http'</span>
|
||||||
|
<span class="nb">require</span> <span class="s1">'uri'</span>
|
||||||
|
|
||||||
|
<span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="no">URI</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="s1">'{{ ping_url }}'</span><span class="p">))</span>
|
||||||
|
</pre></div>
|
4
templates/front/snippets/ruby.txt
Normal file
4
templates/front/snippets/ruby.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
require 'net/http'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
|
Net::HTTP.get(URI.parse('PING_URL'))
|
@ -41,6 +41,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#python" data-toggle="tab">Python</a>
|
<a href="#python" data-toggle="tab">Python</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="hidden-xs">
|
||||||
|
<a href="#ruby" data-toggle="tab">Ruby</a>
|
||||||
|
</li>
|
||||||
<li class="hidden-xs">
|
<li class="hidden-xs">
|
||||||
<a href="#node" data-toggle="tab">Node.js</a>
|
<a href="#node" data-toggle="tab">Node.js</a>
|
||||||
</li>
|
</li>
|
||||||
@ -69,6 +72,9 @@
|
|||||||
{% include "front/snippets/python_urllib2.html" %}
|
{% include "front/snippets/python_urllib2.html" %}
|
||||||
{% include "front/snippets/python_requests.html" %}
|
{% include "front/snippets/python_requests.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="ruby">
|
||||||
|
{% include "front/snippets/ruby.html" %}
|
||||||
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="node">
|
<div role="tabpanel" class="tab-pane" id="node">
|
||||||
{% include "front/snippets/node.html" %}
|
{% include "front/snippets/node.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user