Skip to content

Instantly share code, notes, and snippets.

#Middleware included in Rack

Name Description
URLMap to route to multiple applications inside the same process.
CommonLogger for creating Apache-style logfiles.
ShowExceptions for catching unhandled exceptions and presenting them in a nice and helpful way with clickable backtrace.
File for serving static files.
Static intercepts requests for static files
Deflater enables compression of http responses.

Serving Flask under a subpath

Your Flask app object implements the __call__ method, which means it can be called like a regular function. When your WSGI container receives a HTTP request it calls your app with the environ dict and the start_response callable. WSGI is specified in PEP 0333. The two relevant environ variables are:

SCRIPT_NAME
The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server.

@Larivact
Larivact / config_dict.py
Last active July 21, 2016 06:28
A cool experimental version of configparser. The CFG file syntax has to be: none, true, false, 'string', 1234
class ConfigDict():
comment_delimiters = ('#', ';')
def __init__(self, path):
self.path = path
self.lines = None
self.data = None
def read(self):
with open(self.path) as f: