{ "info": { "author": "Ryan Northey", "author_email": "ryan@3ca.org.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Detailed documentation\n**********************\n\naio.http.server\n===============\n\nHTTP server for the aio_ asyncio framework\n\n.. _aio: https://github.com/phlax/aio\n\n\nBuild status\n------------\n\n.. image:: https://travis-ci.org/phlax/aio.http.server.svg?branch=master\n\t :target: https://travis-ci.org/phlax/aio.http.server\n\n\nInstallation\n------------\n\nRequires python >= 3.4\n\nInstall with:\n\n.. code:: bash\n\n\t pip install aio.http.server\n\n\nQuick start - Hello world http server\n-------------------------------------\n\nCreate a web server that says hello\n\nSave the following into a file \"hello.conf\"\n\n.. code:: ini\n\t \n\t [server/my_server]\n\t factory = aio.http.server.factory\n\t port = 8080\n\t protocol = my_example.protocol\n\n\t \nAnd save the following into a file named my_example.py\n\t \n.. code:: python\n\n\t import asyncio\n\t import aiohttp\n\n\t import aio.app\n\n\t @aio.app.server.protocol\n\t def protocol(name):\n\t loop = asyncio.get_event_loop()\n\t webapp = aiohttp.web.Application(loop=loop)\n\n\t @asyncio.coroutine\n\t def handle_hello_world(webapp):\n\t return aiohttp.web.Response(body=b\"Hello, world\")\n\n\t webapp.router.add_route(\"GET\", \"/\", handle_hello_world)\n\t return webapp.make_handler()\n\t \t \t \n\nRun with the aio run command\n\n.. code:: bash\n\n\t aio run -c hello.conf\n\n\t \n\n\naio.http.server usage\n=====================\n\n\nConfiguration\n-------------\n\nCreate a server config with the aio.http.server.factory factory and suppressing normal output\n\n>>> config = \"\"\"\n... [aio]\n... log_level = ERROR\n... \n... [server/test]\n... factory: aio.http.server.factory\n... port: 7070\n... \"\"\" \n\n\nRunning an http server\n----------------------\n\nBy default the http server will respond with a 404 as there are no routes set up\n\n>>> import asyncio\n>>> import aiohttp\n>>> from aio.app.runner import runner\n>>> import aio.testing\n\n>>> @aio.testing.run_forever(sleep=1)\n... def run_http_server():\n... runner(['run'], config_string=config)\n... \n... def call_http_server():\n... result = yield from (\n... yield from aiohttp.request(\n... \"GET\", \"http://localhost:7070\")).read() \n... print(result)\n... \n... return call_http_server\n\n>>> run_http_server()\nb'404: Not Found'\n\nThe server object is accessible from the aio.app.servers[{name}] var\n\n>>> import aio.app\n \n>>> aio.app.servers['test']\n\n\nLets clear the app\n\n>>> aio.app.clear()\n \n\nRunning the server with a custom protocol\n-----------------------------------------\n\nIf you specify a protocol in the \"server/\" config, the http server will use that function as a protocol factory.\n\nThe function should be a coroutine and is called with the name of the server\n\n>>> config_with_protocol = \"\"\"\n... [aio]\n... log_level = ERROR\n... \n... [server/test]\n... factory = aio.http.server.factory\n... protocol = aio.http.server.tests._example_http_protocol\n... port = 7070\n... \"\"\" \n\nWe need to decorate the protocol with aio.app.server.protocol\n\n>>> @aio.app.server.protocol\n... def http_protocol(name):\n... loop = asyncio.get_event_loop()\n... http_app = aiohttp.web.Application(loop=loop)\n... http_app['name'] = name\n... \n... @asyncio.coroutine \n... def handle_hello_world(http_app):\n... return aiohttp.web.Response(body=b\"Hello, world\")\n... \n... http_app.router.add_route(\"GET\", \"/\", handle_hello_world)\n... return http_app.make_handler()\n\n>>> aio.http.server.tests._example_http_protocol = http_protocol\n\n>>> @aio.testing.run_forever(sleep=1)\n... def run_http_server():\n... runner(['run'], config_string=config_with_protocol)\n... \n... def call_http_server():\n... result = yield from (\n... yield from aiohttp.request(\n... \"GET\", \"http://localhost:7070\")).read()\n... \n... print(result)\n... \n... return call_http_server\n \n>>> run_http_server()\nb'Hello, world'", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/phlax/aio.http.server", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "aio.http.server", "package_url": "https://pypi.org/project/aio.http.server/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/aio.http.server/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/phlax/aio.http.server" }, "release_url": "https://pypi.org/project/aio.http.server/0.1.4/", "requires_dist": null, "requires_python": null, "summary": "HTTP server for the aio asyncio framework", "version": "0.1.4" }, "last_serial": 1563812, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "379eb5d640fa1ce3b65214734e5420dc", "sha256": "7910138f0979076f603bbab13456dfc2c996b4ce65fa49e0fb665b62c1eef182" }, "downloads": -1, "filename": "aio.http.server-0.0.1.tar.gz", "has_sig": false, "md5_digest": "379eb5d640fa1ce3b65214734e5420dc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4385, "upload_time": "2015-05-22T18:11:18", "url": "https://files.pythonhosted.org/packages/28/2f/55fe08d4baf4fe4853e237ae0df15fdaf5b8239794e344c5e4207d6121aa/aio.http.server-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "65873c875b08dab9280c84bd05469911", "sha256": "7d80d18592c44f8ea800c5f54348107ec68a03c2f71cbf85a824e70358f8cbe7" }, "downloads": -1, "filename": "aio.http.server-0.0.3.tar.gz", "has_sig": false, "md5_digest": "65873c875b08dab9280c84bd05469911", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4385, "upload_time": "2015-05-22T18:27:56", "url": "https://files.pythonhosted.org/packages/d6/59/595a800c344044748b350064ed9a727ed13a898841d1424407fe5b529d78/aio.http.server-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "1b86a1a91819e24a59c6ebe6343bad22", "sha256": "65489fba26d1894923191b8f34cbcbf304fac0910beb79dbd92beaa020a4e156" }, "downloads": -1, "filename": "aio.http.server-0.0.4.tar.gz", "has_sig": false, "md5_digest": "1b86a1a91819e24a59c6ebe6343bad22", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4382, "upload_time": "2015-05-23T01:08:50", "url": "https://files.pythonhosted.org/packages/a5/55/a3d059f32e04555ec0c661c280e07918f58ff1c6230062178e6aa616dc68/aio.http.server-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "05ff56aaea309008c610249d8fa15854", "sha256": "06565660623bf132eb99a4c97cb81df2c96a6e178c7a9db7dc59c640806186c5" }, "downloads": -1, "filename": "aio.http.server-0.0.5.tar.gz", "has_sig": false, "md5_digest": "05ff56aaea309008c610249d8fa15854", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4383, "upload_time": "2015-05-23T21:03:41", "url": "https://files.pythonhosted.org/packages/f2/c6/bbf20cb7cea01caaef2fe1c650b1beaf2a55f1f8ec69783cd0690d89f449/aio.http.server-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "9402e3ce945f3d0b1bca0fc3fb039b2b", "sha256": "8442b52317a7759fcf6cd1006195e20a19fecd3103dfe399709e77f69fa0fda7" }, "downloads": -1, "filename": "aio.http.server-0.0.6.tar.gz", "has_sig": false, "md5_digest": "9402e3ce945f3d0b1bca0fc3fb039b2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4381, "upload_time": "2015-05-23T22:40:48", "url": "https://files.pythonhosted.org/packages/2b/6e/f003368f32ee6e823efcda06cd36358a0ec1570d1438e107e53d297b1bd8/aio.http.server-0.0.6.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "8d685ec8e111b1f11d018f980898f9f7", "sha256": "b1940d7d8d7e23bca31e45d57671317646e65191b83f11240c76909d10d30935" }, "downloads": -1, "filename": "aio.http.server-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8d685ec8e111b1f11d018f980898f9f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4464, "upload_time": "2015-05-24T21:41:21", "url": "https://files.pythonhosted.org/packages/97/f7/d1e8c64a7efce11fd6dc7f4b73e896b3d700260ddfd187daca6510457902/aio.http.server-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "aa2d810bfe5e3f334901446224388519", "sha256": "c6a5a2e3b929aa1d9ca59557f07214f388f01475b621f8a2489ef18b84bad087" }, "downloads": -1, "filename": "aio.http.server-0.1.1.tar.gz", "has_sig": false, "md5_digest": "aa2d810bfe5e3f334901446224388519", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4540, "upload_time": "2015-05-25T17:54:30", "url": "https://files.pythonhosted.org/packages/6e/3f/a127eced6e5c629064cbea2ce5e9ca692c83014a61fa23dc36d4ea4d71f9/aio.http.server-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "976781d20bee2286cdb2c9956dd6b2cd", "sha256": "6ef8c756c46b7efee5e8de790e3dcac6cb2004562b9d2b54318a7abb3aef96c4" }, "downloads": -1, "filename": "aio.http.server-0.1.2.tar.gz", "has_sig": false, "md5_digest": "976781d20bee2286cdb2c9956dd6b2cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4534, "upload_time": "2015-05-25T17:59:25", "url": "https://files.pythonhosted.org/packages/34/ac/093e18687ef5d17c0bbd50cf3bd20b7acfdaf06e0744f9f9133194e4ffc6/aio.http.server-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "6b27e0e911c828b6a16cfef9f8cd0547", "sha256": "ca83c9e2643fd06a45942416e672307730687d6f28725511cc7200ea645d6ae2" }, "downloads": -1, "filename": "aio.http.server-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6b27e0e911c828b6a16cfef9f8cd0547", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4543, "upload_time": "2015-05-25T18:01:02", "url": "https://files.pythonhosted.org/packages/d4/4f/2666628c467be707eae27d904adac740c31f517a30bc30433be7332bfb46/aio.http.server-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "01d66a57c4720c85d25a5fd6357e907b", "sha256": "7e416ad3d553007252b09602336770dc1dc9d715fc5c3d28a485cbad1736167d" }, "downloads": -1, "filename": "aio.http.server-0.1.4.tar.gz", "has_sig": false, "md5_digest": "01d66a57c4720c85d25a5fd6357e907b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4232, "upload_time": "2015-05-26T22:15:16", "url": "https://files.pythonhosted.org/packages/bd/f2/31c2c65ec006b7954aa627bb6c44b17e8d209dac9be6c9b0fd4a1c3fce1d/aio.http.server-0.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "01d66a57c4720c85d25a5fd6357e907b", "sha256": "7e416ad3d553007252b09602336770dc1dc9d715fc5c3d28a485cbad1736167d" }, "downloads": -1, "filename": "aio.http.server-0.1.4.tar.gz", "has_sig": false, "md5_digest": "01d66a57c4720c85d25a5fd6357e907b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4232, "upload_time": "2015-05-26T22:15:16", "url": "https://files.pythonhosted.org/packages/bd/f2/31c2c65ec006b7954aa627bb6c44b17e8d209dac9be6c9b0fd4a1c3fce1d/aio.http.server-0.1.4.tar.gz" } ] }