{ "info": { "author": "Asbjorn Enge", "author_email": "asbjorn@asbjornenge.com", "bugtrack_url": null, "classifiers": [], "description": "===============\nCentipede 0.2.5\n===============\n\nCentipede is a WSGI microframework with a simple decorator based router. It's strength is that it models the technology in use and tries not to confuse developers with complex patterns and tricks. It inherits strongly from urlrelay_.\n\nInstallation\n============\n::\n\n $ pip install centipede\n\nDefining handlers\n=================\nWith Centipede you expose functions to urls. Functions either return a **string** or a **tuple**. A string is treated as the document body, http status is set to *200 OK* and returned to the browser. Should you return a tuple, *status code*, *body* and *headers* are expected. The expose decorator also supports a few arguments.\n\n::\n\n from centipede import expose, app\n\n @expose('^/$')\n def index(request):\n \"\"\" Simple Hello\n \"\"\"\n return 'Hello IgglePigglePartyPants!'\n\n @expose('^/google$')\n def index(request):\n \"\"\" A redirect\n \"\"\"\n return (307, '', {'Location':'http://google.com'})\n \n import json\n \n @expose('^/twitter','POST',content_type='application/json')\n def tweet_post(request):\n \"\"\" Tweet\n \"\"\"\n data = request['data']\n text = data['text']\n user = data['user']\n tweet = magic.tweet(text, user)\n return json.dumps(tweet)\n \n @expose('^/twitter/(?P\\w+)$','GET',content_type='application/json')\n def twitter(request):\n \"\"\" Get a tweet\n \"\"\"\n id = req['wsgiorg.routing_args'][1]['tweet']\n meta = request['params']['metadata']\n tweet = magic.get_tweet(id, meta=meta)\n return json.dumps(tweet)\n \n application = app()\n\n\nExpose arguments\n================\nThe expose decorator looks like this::\n\n expose(url_pattern, method='GET', content_type='text/html', charset='UTF-8')\n\nRequest\n=======\nThe parameter passed to the functions exposed (*request* in the examples above) is the WSGI environ_ dictionary. For convenience the **query string parameters** and **form data** parameters are packed into environ's **params** and **data** keys.\n\nQuery string data\n-----------------\nFor convenience, query string parameters are available as a dictionary in environ's **params** key. Both key and value are unquoted using *urllib.unquote*. Unquoted parameters are passed to the **params_raw** key.\n\n\nForm data\n---------\nFor convenience, form data are available as a dictionary in environ's **data** key. Both key and value are unquoted using *urllib.unquote_plus*. Unquoted parameters are passed to the **data_raw** key.\n\n\nTemplates\n=========\nI would recommend keeping your html templates static on the client side and use a javascript template library. But if you really need some server side templating, have a look at mako.\n\nStatic files\n============\nFor production you should always host your static files directly from the webserver or a varnish cache or something. But for development purposes you can have centipede serve your static files by passing *app* a parameter::\n\n\tapp('path/to/static')\n\nDeployment\n==========\nFor deployment it is a good idea to run your centipede application behind a good WSGI server. There is a bunch_. Gunicorn_ is good. I usually end up running uwsgi_ behind nginx.\n\nChangelog\n=========\n\n0.2.5\n-----\n* Separated query string params and form data\n* Form data in *data* key\n* Query string params in *params* key\n* Improved error handling for unpacking params (needs more work)\n\n0.2.4\n-----\n* Added urllib.unquote_plus for POST parameters.\n* Added *params_raw* key to environ in case urllib.unquote mess up your parameters.\n\n0.2.3\n-----\n* Added *params* key to environ for easy parameter access.\n* Added urllib.unquote for params\n\nenjoy.\n\n.. _urlrelay: http://pypi.python.org/pypi/urlrelay/\n.. _environ: http://www.python.org/dev/peps/pep-0333/#environ-variables\n.. _Gunicorn: http://gunicorn.org/\n.. _uwsgi: http://projects.unbit.it/uwsgi/\n.. _bunch: http://www.wsgi.org/en/latest/servers.html", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://centipede.asbjornenge.com", "keywords": null, "license": "FreeBSD", "maintainer": null, "maintainer_email": null, "name": "centipede", "package_url": "https://pypi.org/project/centipede/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/centipede/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://centipede.asbjornenge.com" }, "release_url": "https://pypi.org/project/centipede/0.2.5/", "requires_dist": null, "requires_python": null, "summary": "Centipede is a WSGI microframework with a simple decorator based router.", "version": "0.2.5" }, "last_serial": 758833, "releases": { "0.1.1dev": [ { "comment_text": "", "digests": { "md5": "965ce0df8cdc7c98a8c685906bff029b", "sha256": "68993407f5bfb328e5c8843006a43f1f0f9f0a52b3c0916be1d8b8311ada0490" }, "downloads": -1, "filename": "centipede-0.1.1dev.tar.gz", "has_sig": false, "md5_digest": "965ce0df8cdc7c98a8c685906bff029b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2308, "upload_time": "2012-01-28T00:24:09", "url": "https://files.pythonhosted.org/packages/3f/36/79286bca128ec4f4baaf456ba0fe73784f7b66714e9162362a3062339fe9/centipede-0.1.1dev.tar.gz" } ], "0.2.1dev": [ { "comment_text": "", "digests": { "md5": "d680cf5483f6c558bc2caa5eecdf7709", "sha256": "89a53b00a3263e563a20e920e1305811170f5b7268d3725b76a55b252b8db523" }, "downloads": -1, "filename": "centipede-0.2.1dev.tar.gz", "has_sig": false, "md5_digest": "d680cf5483f6c558bc2caa5eecdf7709", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2811, "upload_time": "2012-01-29T21:58:14", "url": "https://files.pythonhosted.org/packages/ac/79/58ee4bb7e53e75d8c54f19c36d1066581fc72db85eb3fbdd0c38d75db69e/centipede-0.2.1dev.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "863de307dc113a81983d6bca3c01a352", "sha256": "4666aebea5b271ded4b32814479484e02c071637fd75a41d5c5b49d6dadec7d9" }, "downloads": -1, "filename": "centipede-0.2.2.tar.gz", "has_sig": false, "md5_digest": "863de307dc113a81983d6bca3c01a352", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2951, "upload_time": "2012-02-04T23:12:33", "url": "https://files.pythonhosted.org/packages/27/ce/6de4bd11e0b2b9ae5d8f30c0eb149ecfa16ab39ab0571e7e72f3be54d8f4/centipede-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "d4d8ac8733085724e2bcbd0d7b8161e9", "sha256": "fe7947694149b193ea6483a59d8201878dd2e7115c7b883c3d919dfab17f184a" }, "downloads": -1, "filename": "centipede-0.2.3.tar.gz", "has_sig": false, "md5_digest": "d4d8ac8733085724e2bcbd0d7b8161e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2974, "upload_time": "2012-02-05T13:41:07", "url": "https://files.pythonhosted.org/packages/1e/21/8133fd07039ad528260ff9073f8680cb690094f2f190b986049bd89efb29/centipede-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "aea8a68fed894daa95c0246055af1629", "sha256": "23a14d96de0eb571c7723505ef81b3570f7c0c09896722b3793d53a9f00e46e5" }, "downloads": -1, "filename": "centipede-0.2.4.tar.gz", "has_sig": false, "md5_digest": "aea8a68fed894daa95c0246055af1629", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3186, "upload_time": "2012-02-06T09:57:45", "url": "https://files.pythonhosted.org/packages/c1/ee/65907dd726d3aa50f96b82a7d35782e4393de19eb7b844a2a7cda07d552b/centipede-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "07a007d0569543ae085ac6ff28675947", "sha256": "3c88efac323e12e2117852f5ee594eb60230a9bb257effe9c586d46a7466ddd3" }, "downloads": -1, "filename": "centipede-0.2.5.tar.gz", "has_sig": false, "md5_digest": "07a007d0569543ae085ac6ff28675947", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3813, "upload_time": "2012-02-15T09:26:53", "url": "https://files.pythonhosted.org/packages/bd/56/90e4a34763e46191c495cf1ee0711a8fb91eeada10de44e93cf138fc495d/centipede-0.2.5.tar.gz" } ], "0.2dev": [ { "comment_text": "", "digests": { "md5": "be750cc8bfb975d4a9e2518683a95bdb", "sha256": "d9f9fc93f6a036374dcdb2d2d987316d2b00dc6b682c57f6a0a08f257be3506c" }, "downloads": -1, "filename": "centipede-0.2dev.tar.gz", "has_sig": false, "md5_digest": "be750cc8bfb975d4a9e2518683a95bdb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2724, "upload_time": "2012-01-28T11:49:11", "url": "https://files.pythonhosted.org/packages/ac/97/6ad65111f8bc9faad29220ea000965028a5fa049912e362aae52afb1105d/centipede-0.2dev.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "07a007d0569543ae085ac6ff28675947", "sha256": "3c88efac323e12e2117852f5ee594eb60230a9bb257effe9c586d46a7466ddd3" }, "downloads": -1, "filename": "centipede-0.2.5.tar.gz", "has_sig": false, "md5_digest": "07a007d0569543ae085ac6ff28675947", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3813, "upload_time": "2012-02-15T09:26:53", "url": "https://files.pythonhosted.org/packages/bd/56/90e4a34763e46191c495cf1ee0711a8fb91eeada10de44e93cf138fc495d/centipede-0.2.5.tar.gz" } ] }