{ "info": { "author": "Chunwei Yan", "author_email": "yanchunwei@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta" ], "description": "Swinf Web Frame\r\n================\r\n\r\nSwinf is a simple micro-framework for small web application and has no dependencies other than the Python Standard Liberaty.\r\n\r\nIt offers a built-in HTTP Server, and a simple route binding mechanism.\r\n\r\n\r\nCommands\r\n---------\r\nrun command : **swinf-admin.py startproject newproject** and swinf will create a project directory.\r\n\r\nInside current project directory, there are a **main.py** and three subdirectories:\r\n\r\ncontroller::\r\n\r\n containing controllers.\r\n\r\nview::\r\n \r\n containing view template files.\r\n\r\n subdirecties:\r\n \r\n static/: contains static files\r\n \r\n static/images: images here\r\n \r\n static/style: css files here\r\n\r\n static/script: js files here\r\n\r\n static/files: other static files here\r\n\r\nmodel::\r\n \r\n you can put your database controlling code here.\r\n\r\n\r\nYou can add some controllers in `controller` directory and run `main.py`, and it will work.\r\n\r\nTemplate\r\n---------\r\nCurrently, swinf have a simple template engine called `SimpleTemplate`.\r\n\r\nthe tpl syntax follows below\r\n\r\n.. code-block:: html\r\n\r\n \r\n\r\n {%\r\n # multiline code\r\n\r\n def bold_wrapper(txt):\r\n return \"\" + txt + \"\"\r\n endef\r\n %}\r\n\r\n %% # sigleline code\r\n %% if name:\r\n

hello {{name}}!

\r\n %% else:\r\n

Hello World!

\r\n %% endif\r\n\r\n \r\n\r\nTo use the **template**, you can use code like below:\r\n\r\n.. code-block:: python\r\n \r\n from swinf.template import template\r\n # pass tpl source\r\n html = template(\"

hello {{name}}\", name='world')\r\n\r\n # pass a tpl file\r\n html = template(path='index.tpl', name='world')\r\n\r\n\r\nExample\r\n--------\r\nIn swinf, there is no `urls.py`-like config file, instead, there are two simple route-config ways:\r\n\r\n* A Bottle.py like route binding mechanism\r\n\r\n.. code-block:: python\r\n \r\n from swinf.swinf import run\r\n from swinf.selector import route\r\n \r\n # a simple controller \r\n @route('/hello/:name')\r\n def hello(name):\r\n return '

Hello %s!

' % name.title()\r\n\r\n run(host='localhost', port=8080)\r\n\r\n* Much simpler route binding mechanism\r\n\r\n.. code-block:: python\r\n\r\n # module1.py\r\n from swinf.selector import handler\r\n\r\n # --------- your code here -----------\r\n\r\n @handler(\"GET\")\r\n def hello():\r\n return '

Hello

' \r\n\r\n @handler(\"GET\")\r\n def world():\r\n return '

World

' \r\n\r\n\r\nThis will will automatically bind route **/module1/hello** to handler **controller.module1.hello** and **/module1/world** to handler **controller.module1.world**. \r\n\r\nYou don't have to add routes manully.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/swinf/Swinf/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://swinf.github.com/Swinf", "keywords": "micro web framework", "license": "MIT", "maintainer": "Chunwei Yan", "maintainer_email": "yanchunwei@outlook.com", "name": "swinf", "package_url": "https://pypi.org/project/swinf/", "platform": "Python 2.7", "project_url": "https://pypi.org/project/swinf/", "project_urls": { "Download": "https://github.com/swinf/Swinf/tarball/master", "Homepage": "http://swinf.github.com/Swinf" }, "release_url": "https://pypi.org/project/swinf/0.0.5/", "requires_dist": null, "requires_python": null, "summary": "Swinf is a simple micro-framework for small web application and has no dependencies other than the Python Standard Liberaty.", "version": "0.0.5" }, "last_serial": 800293, "releases": { "0.0.4": [], "0.0.5": [ { "comment_text": "update version", "digests": { "md5": "fe28b576fc43c484a62bd5b3751444f1", "sha256": "f963cf0ea0cca7265aeec72c17ca6487b0eb95c91fe9b7e4bef664f15b3f239f" }, "downloads": -1, "filename": "swinf-0.0.5.tar.gz", "has_sig": false, "md5_digest": "fe28b576fc43c484a62bd5b3751444f1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 29120, "upload_time": "2013-03-25T06:21:41", "url": "https://files.pythonhosted.org/packages/14/3a/cd456d0969c4982b522b3e07a11b3d168725b01e2f0d75d02912681ecfa7/swinf-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "update version", "digests": { "md5": "fe28b576fc43c484a62bd5b3751444f1", "sha256": "f963cf0ea0cca7265aeec72c17ca6487b0eb95c91fe9b7e4bef664f15b3f239f" }, "downloads": -1, "filename": "swinf-0.0.5.tar.gz", "has_sig": false, "md5_digest": "fe28b576fc43c484a62bd5b3751444f1", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 29120, "upload_time": "2013-03-25T06:21:41", "url": "https://files.pythonhosted.org/packages/14/3a/cd456d0969c4982b522b3e07a11b3d168725b01e2f0d75d02912681ecfa7/swinf-0.0.5.tar.gz" } ] }