{ "info": { "author": "Chen Gang", "author_email": "yikuyiku.com@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3 :: Only", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Multimedia :: Video :: Conversion" ], "description": "|\n\nNAME\n====\n\n x100http, web framework support customing file upload processing\n\n\n|\n\nSYNOPSIS\n========\n\n.. code-block::\n\n\n from x100http import X100HTTP\n\n app = X100HTTP()\n\n def hello_world(request):\n remote_ip = request.get_remote_ip()\n response = \"
hello, \" + remote_ip + \"\"\n return response\n\n app.get(\"/\", hello_world)\n app.run(\"0.0.0.0\", 8080)\n\n\n|\n\nDESCRIPTION\n===========\n\n x100http is a lite webframework designed for processing HTTP file upload.\n\n\n|\n\nCLASS X100HTTP\n==============\n\nX100HTTP()\n----------\n return a instance of x100http which wrapped below functions.\n\nrun(listern_ip, listen_port)\n----------------------------\n run a forking server on address ``listern_ip``:``listern_port``\n\nget(url, handler_function)\n--------------------------\n set a route acl of HTTP \"GET\" method.\n\n ``handler_function`` will be called when ``url`` be visited.\n\n ``handler_function`` must return a string as the HTTP response body to the visitor.\n\n struct ``request`` (will explain below) will be passed to the handlder function when it is called.\n\npost(url, handler_function)\n---------------------------\n set a route acl of HTTP \"POST\" method with header \"Content-Type: application/x-www-form-urlencoded\".\n\n ``handler_function`` will be called when HTTP client submit a form with the action ``url``.\n\n ``handler_function`` must return a string as the HTTP response body to the visitor.\n\n struct ``request`` (will explain below) will be passed to the handlder function when it is called.\n\nstatic(url_prefix, file_path, cors=allow_domain)\n------------------------------------------------\n set a route acl for static file\n\n Static file request with ``url_prefix`` will be routing to the file in ``file_path``.\n\n Default value of cors is \"*\", allow all CORS request matching this route rule.\n\nupload(url, upload_handler_class)\n---------------------------------\n set a route acl of HTTP \"POST\" method with header \"Content-Type: multipart/form-data\".\n\n A new instance of class ``upload_handler_class`` will be created when file upload start.\n\n struct \"request\" (will explain below) will be passed to ``upload_handler_class.upload_start()``.\n\n ``upload_handler_class.upload_process()`` will be called every time when the buffer is full when file uploading.\n\n two args will be passed to ``upload_handler_class.upload_process()``.\n\n first arg is the name of the input in the form, second arg is the content of the input in the form.\n\n the binary content of the upload file will be passed by the second arg.\n\n struct \"request\" (will explain below) will NOT be passed to ``upload_handler_class.upload_finish()``.\n\n ``upload_handler_class.upload_finish()`` will be called when file upload finished, this function must return a string as the HTTP response body to the visitor.\n\n struct \"request\" (will explain below) will be passed to ``upload_handler_class.upload_finish()``.\n\nset_upload_buf_size(buf_size)\n-----------------------------\n set the buffer size of the stream reader while file uploading.\n\n the unit of ``buf_size`` is byte, default value is 4096 byte.\n\n ``upload_handler_class.upload_process()`` will be called to process the buffer every time when the buffer is full.\n\n\n|\n\nROUTING\n=======\n\n x100http route accept a url and a function/class/path.\n\n There are three four of routes - get, post, static and upload.\n\n.. code-block::\n\n app.get(\"/get_imple\", get_simple)\n app.post(\"/post_simple\", post_simple)\n app.upload(\"/upload_simple\", UploadClass)\n app.static(\"/static/test/\", \"/tmp/sta/\")\n\nrouting for HTTP GET can be more flexible like this:\n\n.. code-block::\n\n app.get(\"/one_dir/