mirror of
https://github.com/healthchecks/healthchecks.git
synced 2024-11-23 07:57:39 +00:00
10 lines
999 B
HTML
10 lines
999 B
HTML
<div class="highlight"><pre><span></span><span class="c1"># Using the requests library:</span>
|
|
<span class="kn">import</span> <span class="nn">requests</span>
|
|
|
|
<span class="k">try</span><span class="p">:</span>
|
|
<span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"{{ ping_url }}"</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
|
|
<span class="k">except</span> <span class="n">requests</span><span class="o">.</span><span class="n">RequestException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
|
<span class="c1"># Log ping failure here...</span>
|
|
<span class="nb">print</span><span class="p">(</span><span class="s2">"Ping failed: </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">e</span><span class="p">)</span>
|
|
</pre></div>
|