mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
Merge pull request #50 from FlaPer87/master
Robots Support and Simple Html response
This commit is contained in:
+29
-2
@@ -14,12 +14,12 @@ import time
|
||||
|
||||
import newrelic.agent
|
||||
|
||||
from flask import Flask, Response, request, render_template, redirect, jsonify
|
||||
from flask import Flask, Response, request, render_template, redirect, jsonify, make_response
|
||||
from raven.contrib.flask import Sentry
|
||||
from werkzeug.datastructures import WWWAuthenticate
|
||||
|
||||
from . import filters
|
||||
from .helpers import get_headers, status_code, get_dict, check_basic_auth, check_digest_auth, H
|
||||
from .helpers import get_headers, status_code, get_dict, check_basic_auth, check_digest_auth, H, ROBOT_TXT, ANGRY_ASCII
|
||||
from .utils import weighted_choice
|
||||
from .structures import CaseInsensitiveDict
|
||||
|
||||
@@ -51,6 +51,33 @@ def view_landing_page():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@app.route('/html')
|
||||
def view_html_page():
|
||||
"""Simple Html Page"""
|
||||
|
||||
return render_template('moby.html')
|
||||
|
||||
|
||||
@app.route('/robots.txt')
|
||||
def view_robots_page():
|
||||
"""Simple Html Page"""
|
||||
|
||||
response = make_response()
|
||||
response.data = ROBOT_TXT
|
||||
response.content_type = "text/plain"
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/deny')
|
||||
def view_deny_page():
|
||||
"""Simple Html Page"""
|
||||
response = make_response()
|
||||
response.data = ANGRY_ASCII
|
||||
response.content_type = "text/plain"
|
||||
return response
|
||||
# return "YOU SHOULDN'T BE HERE"
|
||||
|
||||
|
||||
@app.route('/ip')
|
||||
def view_origin():
|
||||
"""Returns Origin IP."""
|
||||
|
||||
@@ -45,7 +45,22 @@ ENV_HEADERS = (
|
||||
'X-Forwarded-Port'
|
||||
)
|
||||
|
||||
ROBOT_TXT = """User-agent: *
|
||||
Disallow: /deny
|
||||
"""
|
||||
|
||||
ANGRY_ASCII ="""
|
||||
.-''''''-.
|
||||
.' _ _ '.
|
||||
/ O O \\
|
||||
: :
|
||||
| |
|
||||
: __ :
|
||||
\ .-"` `"-. /
|
||||
'. .'
|
||||
'-......-'
|
||||
YOU SHOUDN'T BE HERE
|
||||
"""
|
||||
|
||||
def get_files():
|
||||
"""Returns files dict from request context."""
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<li><a href="/digest-auth/auth/user/passwd"><code>/digest-auth/:qop/:user/:passwd</code></a> Challenges HTTP Digest Auth.</li>
|
||||
<li><a href="/stream/20"><code>/stream/:n</code></a> Streams <em>n</em>–100 lines.</li>
|
||||
<li><a href="/delay/3"><code>/delay/:n</code></a> Delays responding for <em>n</em>–10 seconds.</li>
|
||||
<li><a href="/html"><code>/html</code></a> Renders an HTML Page</li>
|
||||
<li><a href="/robots.txt"><code>/robots.txt</code></a> Returns some robots.txt rules</li>
|
||||
<li><a href="/deny"><code>/deny</code></a> Denied by robots.txt file</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user