This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
from __future__ import unicode_literals | |
import logging | |
from functools import partial | |
from marrow.script import execute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from __future__ import unicode_literals | |
from alacarte.template.simplithe.html5 import * | |
__all__ = ['theme'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import logging | |
from marrow.server.http import HTTPServer | |
def hello(request): | |
def transcode_video(request): | |
# p-code ahoy! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extensions: | |
- [!!python marrow.mail:DeliveryExtension, *mail] | |
- !!python marrow.mail.logger:LoggerExtension | |
mail: &mail | |
server: localhost | |
user: user | |
password: xyzzy | |
administrator: [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import unicode_literals, print_function | |
"""Compare two algorithms that canonicalize a list of tuples. | |
Python 2.7.0: | |
Good headers: | |
List creation and iteration: 2.98474693298 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the initial idea based on a callback-based async framework. | |
# This assumes yield syntax is mandatory; applications and middleware | |
# must be generators. | |
# This idea should be usable as-is and a fork of m.s.http should be | |
# utilized to explore the concept within the context of a real server. | |
# Combine futures with the dubious (and much-argued) yield reactor | |
# syntax. Yield allows the application to return to the reactor in such | |
# a way as to be able to be resumed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INFO:marrow.server.base:Starting up. | |
INFO:marrow.server.base:Server running with PID 8639, serving on 127.0.0.1:8888. | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient) | |
Completed 1000 requests | |
Completed 2000 requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def null_middleware(app): | |
def middleware(environ): | |
generator = app(environ) | |
result = None | |
while True: | |
result = generator.send(result) | |
try: result = (yield result) | |
except: generator.throw(*sys.exc_info()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(Controller): | |
def __init__(self, id): | |
self.id = id | |
def index(self): | |
return 'mypkg.views.user', dict(id=self.id) | |
def method(self): | |
return 'mypkg.views.method', dict(id=self.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""A transparent caching proxy. | |
To use, simply create a directory and run this script a la: | |
./caching-proxy.py cache | |
Then point your browser's HTTP proxy at localhost:8888. |