Skip to content

Instantly share code, notes, and snippets.

# -*- mode: conf -*-
# vim:ft=cfg
# Config file for Radicale - A simple calendar server
#
# Place it into /etc/radicale/config (global)
# or ~/.config/radicale/config (user)
#
# The current values are the default ones
import flask
app = flask.Flask('testapp')
@app.route('/dir')
def from_dir():
return flask.send_from_directory('data', 'file.txt')
@app.route('/file')
def from_file():
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//watdo//mimedir.icalendar//EN
BEGIN:VTODO
DUE;VALUE=DATE:20140915
LAST-MODIFIED;VALUE=DATE-TIME:20140915T195112Z
STATUS:NEEDS-ACTION
SUMMARY:TEST ONE
UID:abcdef
END:VTODO
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//iOS 6.1.6//EN
VERSION:2.0
BEGIN:VTODO
CREATED:20141207T173149Z
DTSTAMP:20141207T173206Z
LAST-MODIFIED:20141207T173151Z
SEQUENCE:0
STATUS:NEEDS-ACTION
Exception sqlalchemy.exc.InvalidRequestError: InvalidRequestError("This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occuring prematurely) No column item.collection_path is configured on mapper Mapper|DBLine|line... (original cause: UnmappedColumnError: No column item.collection_path is configured on mapper Mapper|DBLine|line...) u'SELECT item.name AS item_name, item.tag AS item_tag, item.collection_path AS item_collection_path \\nFROM item, line \\nWHERE ? = line.item_name AND ? = line.item_collection_path ORDER BY line.timestamp' [immutabledict({})]",) in <bound method Collection.__del__ of <radicale.storage.database.Collection object at 0x7f24cdaf4690>> ignored
# mitsuhiko/flask#637
from flask import send_file, Flask, request
import datetime
app = Flask(__name__)
@app.route('/image/<file_id>')
def images(file_id):
f = open('lel.jpg') # some jpeg file in the same dir
@untitaker
untitaker / gist:5389383
Created April 15, 2013 16:33
Example for using werkzeug.datastructures.native_itermethods
@native_itermethods(['keys', 'values', 'items', 'foo'])
class AwsumDict(object):
def keys(self): # return iterator
def values(self): # return iterator
def items(self): # return iterator
def foo(self): # return iterator
d = AwsumDict()
## Python 2
diff --git a/werkzeug/testsuite/wrappers.py b/werkzeug/testsuite/wrappers.py
index 751880d..cc78030 100644
--- a/werkzeug/testsuite/wrappers.py
+++ b/werkzeug/testsuite/wrappers.py
@@ -50,7 +50,8 @@ def request_demo_app(environ, start_response):
'form': request.form,
'form_as_list': list(request.form.lists()),
'environ': prepare_environ_pickle(request.environ),
- 'data': request.data
+ 'data': request.data,
@untitaker
untitaker / my_module.py
Last active December 19, 2015 23:59
Mocking modules
import sublime
def better_os():
x = sublime.get_os()
if x:
return x.upper()
else:
return None
@untitaker
untitaker / gist:5321447
Last active January 15, 2017 18:13
Werkzeug Python 3 notes