简单的WSGI调度员。
urlrela的Python项目详细描述
简单的url分派器,它基于匹配的正则表达式和可选的http请求方法将http请求传递给wsgi应用程序。
用法示例:
import urlrelay # Simple URL to application mapping @urlrelay.url('^/$') def index(environ, start_response): start_response('200 OK', [('Content-type', 'text/plain')]) return ['Home Page'] # "RESTful" URL to application mapping @urlrelay.url('^/hello_world$', 'GET') def hello_world(environ, start_response): start_response('200 OK', [('Content-type', 'text/plain')]) return ['Hello World'] # URL to on-disk application mapping urlrelay.register('^/ondisk$', 'module.on_disk') if __name__ == '__main__': from wsgiref.simple_server import make_server http = make_server('', 8080, urlrelay.URLRelay()) http.serve_forever()