mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 23:00:18 +00:00
cleanup
This commit is contained in:
+1
-4
@@ -13,7 +13,6 @@ from cStringIO import StringIO
|
||||
from decimal import Decimal
|
||||
from time import time as now
|
||||
|
||||
import omnijson
|
||||
from decorator import decorator
|
||||
from flask import Flask, Response
|
||||
|
||||
@@ -21,7 +20,6 @@ from flask import Flask, Response
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
||||
@decorator
|
||||
def x_runtime(f, *args, **kwargs):
|
||||
"""X-Runtime Flask Response Decorator."""
|
||||
@@ -29,7 +27,7 @@ def x_runtime(f, *args, **kwargs):
|
||||
_t0 = now()
|
||||
r = f(*args, **kwargs)
|
||||
_t1 = now()
|
||||
r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1-_t0)))
|
||||
r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0)))
|
||||
|
||||
return r
|
||||
|
||||
@@ -38,7 +36,6 @@ def x_runtime(f, *args, **kwargs):
|
||||
def gzip(f, *args, **kwargs):
|
||||
"""GZip Flask Response Decorator."""
|
||||
|
||||
|
||||
data = f(*args, **kwargs)
|
||||
|
||||
if isinstance(data, Response):
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ Utility functions.
|
||||
import random
|
||||
import bisect
|
||||
|
||||
|
||||
def weighted_choice(choices):
|
||||
"""Returns a value from choices chosen by weighted random selection
|
||||
|
||||
@@ -26,4 +27,4 @@ def weighted_choice(choices):
|
||||
cum_weights.append(total)
|
||||
x = random.uniform(0, total)
|
||||
i = bisect.bisect(cum_weights, x)
|
||||
return values[i]
|
||||
return values[i]
|
||||
|
||||
Reference in New Issue
Block a user