Skip to content

Instantly share code, notes, and snippets.

View boris317's full-sized avatar

Shawn Adams boris317

View GitHub Profile
def api_url_for(endpoint, **values):
# probably handle missing api_app key in some
# special exception.
api_app = current_app().config["api_app"]
with api_app.app_context():
return url_for(end_point, **values)
import os
class WSGIApp(object):
def __init__(self):
setup_logger(os.environ.get('PYCSW_CONFIG'))
def __call__(self, env, start_repsonse):
""" Do reqeust stuff here """
application = WSGIApp()
existing_hash = {:foo=>"bar"}
other_hash.each_pair do |key, value|
if some_condition
existing_hash[key] = value
end
end
@boris317
boris317 / flask_tar.py
Created September 10, 2012 20:57
Stream a tar file with flask.
import os
from cStringIO import StringIO
import tarfile
from flask import Flask, Response
app = Flask(__name__)
def get_string_io_len(s):
@boris317
boris317 / commafloat_field.py
Created September 4, 2012 19:51
Subclass of wtforms.core.FloatField that handles floats with comma delimiters.
"""
For reference wtforms.core.FloatField
-------------------------------------
class FloatField(Field):
widget = widgets.TextInput()
def __init__(self, label=None, validators=None, **kwargs):
super(FloatField, self).__init__(label, validators, **kwargs)