Ejemplo n.º 1
0
class CustomEncoder(json.JSONEncoder):
    def default(self, obj):
        try:
            u = obj.__str__()
            return u
        except:
            return json.JSONEncoder.default(self, obj)

# Initialize the Flask application
inventory_app = Blueprint('inventory_app', __name__, template_folder='./templates', static_folder='./static', static_url_path = 'static/')
url_pref = '/inventory/'

#sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
#Set to info, debug etc
linv.init_run_log(level_name='warning')

@inventory_app.route("style.css")
def css():
    response = make_response(render_template("inv_style.css"))
    response.headers['Content-type'] = 'text/css'
    # don't cache css file, if in debug mode.
    if True:
        response.headers['Cache-Control'] = 'no-cache, no-store'
    else:
        response.headers['Cache-Control'] = 'public, max-age=600'
    return response

#------ Listing pages -----------------------------------
#Custom error for bad table names
class BadNameError(KeyError):
Ejemplo n.º 2
0
            return u
        except:
            return json.JSONEncoder.default(self, obj)


# Initialize the Flask application
inventory_app = Blueprint('inventory_app',
                          __name__,
                          template_folder='./templates',
                          static_folder='./static',
                          static_url_path='static/')
url_pref = '/inventory/'

#sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
#Set to info, debug etc
linv.init_run_log(level_name='warning')


@inventory_app.route("style.css")
def css():
    response = make_response(render_template("inv_style.css"))
    response.headers['Content-type'] = 'text/css'
    # don't cache css file, if in debug mode.
    if True:
        response.headers['Cache-Control'] = 'no-cache, no-store'
    else:
        response.headers['Cache-Control'] = 'public, max-age=600'
    return response


#------ Listing pages -----------------------------------