Skip to content

Commit

Permalink
Merge pull request #25 from iangreenleaf/https-links
Browse files Browse the repository at this point in the history
Use incoming protocol in bin link
  • Loading branch information
johnsheehan authored Jun 15, 2017
2 parents f841c29 + 85ae720 commit e9e1102
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions requestbin/templates/bin.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% block binurl %}
<a href="/{{bin.name}}?inspect"><i class="icon-circle icon-2x" style="color: rgb{{bin.color}}"></i></a>
<input type="text" value="http://{{host}}/{{bin.name}}" onclick="this.select()" />
<input type="text" value="{{base_url}}/{{bin.name}}" onclick="this.select()" />
{% if bin.private %}<i class="icon-lock"></i>{% endif %}
{% endblock %}

Expand All @@ -19,7 +19,7 @@
<div class="message-list">
<div class="row-fluid">
<div class="span4">
http://{{host}}<br>
{{base_url}}<br>
<span class="method">{{request.method}}</span>
<span class="absolute-path">{{request.path}}</span><span class="querystring">{{request.query_string|to_qs}}</span>
</div>
Expand All @@ -44,7 +44,7 @@

<h4 class="text-center">Bin URL</h4>
<h2 class="text-center">
<input class="xxlarge input-xxlarge" type="text" value="http://{{host}}/{{bin.name}}" onclick="this.select()" style="border-color: rgb{{bin.color}}; border-width: 3px;" /></h2>
<input class="xxlarge input-xxlarge" type="text" value="{{base_url}}/{{bin.name}}" onclick="this.select()" style="border-color: rgb{{bin.color}}; border-width: 3px;" /></h2>
<p class="text-center">{% if bin.private %}This is a private bin. Requests are only viewable from this computer.{% endif %}

<hr>
Expand All @@ -54,17 +54,17 @@ <h2 class="text-center">
<h4>Make a request to get started.</h4>

<h5>cURL</h5>
<pre>curl -X POST -d "fizz=buzz" http://{{host}}/{{bin.name}}</pre>
<pre>curl -X POST -d "fizz=buzz" {{base_url}}/{{bin.name}}</pre>

<h5>Python (with Requests)</h5>
<pre class="prettyprint">import requests, time
r = requests.post('http://{{host}}/{{bin.name}}', data={"ts":time.time()})
r = requests.post('{{base_url}}/{{bin.name}}', data={"ts":time.time()})
print r.status_code
print r.content</pre>

<h5>Node.js (with request)</h5>
<pre class="prettyprint">var request = require('request');
var url ='http://{{host}}/{{bin.name}}'
var url ='{{base_url}}/{{bin.name}}'
request(url, function (error, response, body) {
if (!error) {
console.log(body);
Expand All @@ -73,7 +73,7 @@ <h5>Node.js (with request)</h5>

<h5>Ruby</h5>
<pre class="prettyprint">require 'open-uri'
result = open('http://{{host}}/{{bin.name}}')
result = open('{{base_url}}/{{bin.name}}')
result.lines { |f| f.each_line {|line| p line} }</pre>

<h5>C# / .NET</h5>
Expand All @@ -93,7 +93,7 @@ <h5>C# / .NET</h5>
private static async Task MakeRequest()
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(new Uri("http://{{host}}/{{bin.name}}"));
var response = await httpClient.GetAsync(new Uri("{{base_url}}/{{bin.name}}"));
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
Expand All @@ -110,7 +110,7 @@ <h5>Java</h5>
public class RequestBinTutorial {
public static void main(String[] args) {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("http://{{host}}/{{bin.name}}");
GetMethod method = new GetMethod("{{base_url}}/{{bin.name}}");
try {
int statusCode = client.executeMethod(method);
byte[] responseBody = method.getResponseBody();
Expand All @@ -126,7 +126,7 @@ <h5>Java</h5>

<h5>PHP</h5>
<pre class="prettyprint">&lt;?php
$result = file_get_contents('http://{{host}}/{{bin.name}}');
$result = file_get_contents('{{base_url}}/{{bin.name}}');
echo $result;
?&gt;</pre>

Expand Down
2 changes: 1 addition & 1 deletion requestbin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def bin(name):
update_recent_bins(name)
return render_template('bin.html',
bin=bin,
host=request.host)
base_url=request.scheme+'://'+request.host)
else:
db.create_request(bin, request)
resp = make_response("ok\n")
Expand Down

0 comments on commit e9e1102

Please sign in to comment.