{ "info": { "author": "Xiangkui Li", "author_email": "1749498702@qq.com", "bugtrack_url": null, "classifiers": [], "description": "# py4js\npy4js is a fast and simple micro-framework for small web applications. Its goal is to enable you to develop\nweb applications in a simple and understandable way. \n\nWith it, you don't need to know the HTTP protocol, or how Python communicates with JavaScript. You can use Python functions in JavaScript just like native JavaScript functions.\n\n## Usage steps\n\n### Step 1\nInstall py4js package: `pip install py4js` or `pip3 install py4js`\n\n### Step 2\nFirst, create a package, named service, and then create a Python file in the package, such as `hello.py`:\n```python\ndef say_hello(name):\n \"\"\"\n say hello test\n\n :param name:\n :return:\n \"\"\"\n return 'Hello %s!' % name\n```\n\n### Step 3\nCreate a Python file that is at the same level as the service package, such as `main.py`:\n```python\nfrom py4js import Server\n\nServer().run()\n```\nThen run it(By default, the server will launch wsgiref server at port `5000`. You can also use other port and wsgi server).\n\n### Step 4\nCreate a HTML file, anywhere, such as `index.html`:\n```html\n\n\n\n \n hello\n \n\n\n \n\n\n```\n\nOpen the `index.html`in browser and you will see the alert message:\n![image](https://github.com/lixk/py4js/raw/master/sample/screenshots/alert-hello.png)\n\nIt's so easy, yes?\n\n## Server\n### Server parameters\nThe server has several startup parameters that can be specified, for example:\n\n| Name | Description |\n| :--- | :--- |\n| host | Server address to bind to(default: `0.0.0.0`). Pass `0.0.0.0` to listens on all services including the external one. |\n| port | Server port to bind to(default: 5000). Values below 1024 require root privileges. if port is None, server will use a random port. |\n| server | Specify the server adapter to use. For more details: [Server adapter](#server-adapter). (default: `wsgiref`, others: `paste`/`waitress`/`gevent`/`cherrypy`/`gunicorn`.etc). |\n| service_package | A package that will be scanned by the server. All modules and public functions in the package will be loaded as service for JavaScript. Default package name is `service`, also you can change it to another name if you like. |\n| js_route | the path of JavaScript for browser to load. |\n| access_control_allow_origin | default: `*` , all cross domain requests are allowed. |\n\n### Server adapter\nAs the py4js server is based on Bottle, the built-in default server is based on wsgiref WSGIServer. This non-threading HTTP server may become a performance bottleneck when server load increases. \nSo it's better to use a different server that is either multi-threaded or supports asynchronous IO.\n\nBottle ships with a lot of ready-to-use adapters for the most common WSGI servers, such as:\n`cherrypy`, `paste`, `waitress`, `gevent`, `eventlet`, `tornado`, `twisted`.etc. \nUsage:\n 1. waitress\n ```python\n from py4js import Server\n\n Server(server='waitress').run()\n ```\n If you haven't installed the `waitress` package, please install it first by `pip install waitress` or `pip3 install waitress`.\n\n 2. gevent\n ```python\n from gevent import monkey\n\n from py4js import Server\n \n monkey.patch_all()\n \n Server(server='gevent').run()\n ```\n If you haven't installed the `gevent` package, please install it first by `pip install gevent` or `pip3 install gevent`. \n As `gevent` is Asynchronous, the server can be very fast, can handle a virtually unlimited number of concurrent connections and are easy to manage.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lixk/py4js", "keywords": "pip,py4js", "license": "MIT Licence", "maintainer": "", "maintainer_email": "", "name": "py4js", "package_url": "https://pypi.org/project/py4js/", "platform": "any", "project_url": "https://pypi.org/project/py4js/", "project_urls": { "Homepage": "https://github.com/lixk/py4js" }, "release_url": "https://pypi.org/project/py4js/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "a fast and simple micro-framework for small web applications", "version": "0.1.2" }, "last_serial": 4425717, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "841286764b7b3a9f7d6fb363cd21e73b", "sha256": "32385eb82feeb5a100f9afe1ca941abcfd0af89511fae01261c79e8f452747ac" }, "downloads": -1, "filename": "py4js-0.1.0.tar.gz", "has_sig": false, "md5_digest": "841286764b7b3a9f7d6fb363cd21e73b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4752, "upload_time": "2018-10-28T10:49:17", "url": "https://files.pythonhosted.org/packages/06/0b/2026a194c042f925e369a9d38721ae3192e6337bbd113de3a3d70f12240b/py4js-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "8465533fafd100d739af24924849b323", "sha256": "53473624474e25bf9b9814e90b3057d1b4fbaa453143879e070547bd1f33535e" }, "downloads": -1, "filename": "py4js-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8465533fafd100d739af24924849b323", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5197, "upload_time": "2018-10-28T11:04:01", "url": "https://files.pythonhosted.org/packages/e4/0c/ceeb3356593104ba036f0aa59afd268802b3f4186232040ca12a539829bd/py4js-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "0b5b6b54f70d2007b4156f966447ecd4", "sha256": "53a589a2d8d60cc3c89a4421057ded2c7449f8c0b763b0ae9bcc0308dfcbcea8" }, "downloads": -1, "filename": "py4js-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0b5b6b54f70d2007b4156f966447ecd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2018-10-29T01:44:16", "url": "https://files.pythonhosted.org/packages/56/8b/25a3dcd9b819ea8b0aaaba45f7346a175656c25642912fdbe2e9cb343cef/py4js-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0b5b6b54f70d2007b4156f966447ecd4", "sha256": "53a589a2d8d60cc3c89a4421057ded2c7449f8c0b763b0ae9bcc0308dfcbcea8" }, "downloads": -1, "filename": "py4js-0.1.2.tar.gz", "has_sig": false, "md5_digest": "0b5b6b54f70d2007b4156f966447ecd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5251, "upload_time": "2018-10-29T01:44:16", "url": "https://files.pythonhosted.org/packages/56/8b/25a3dcd9b819ea8b0aaaba45f7346a175656c25642912fdbe2e9cb343cef/py4js-0.1.2.tar.gz" } ] }