{ "info": { "author": "yumoqing", "author_email": "yumoqing@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# ahserver\n\nahserver is a http(s) server base on aiohttp asynchronous framework.\n\nahserver capabilities:\n* user authorization and authentication support\n* https support\n* processor for registed file type\n* pre-defined variables and function can be called by processors\n* multiple database connection and connection pool\n* a easy way to wrap SQL\n* configure data from json file stored at ./conf/config.json\n* upload file auto save under config.filesroot folder\n* i18n support\n* processors include:\n\t+ 'dspy' file subffix by '.dspy', is process as a python script\n\t+ 'tmpl' files subffix by '.tmpl', is process as a template\n\t+ 'md' files subffix by '.md', is process as a markdown file\n\t+ 'xlsxds' files subffix by '.xlsxds' is process as a data source from xlsx file\n\t+ 'sqlds' files subffixed by '.sqlds' is process as a data source from database via a sql command\n\n## Requirements\n\nsee requirements.txt\n\n[pyutils](https://github.com/yumoqing/pyutils)\n\n[sqlor](https://github.com/yumoqing/sqlor)\n\n## How to use\nsee ah.py\n\n```\nfrom ahserver.configuredServer import ConfiguredServer\n\nif __name__ == '__main__':\n\tserver = ConfiguredServer()\n\tserver.run()\n```\n\n## Folder structure\n\n+ app\n+ |-ah.py\n+ |--ahserver\n+ |-conf\n+ |-config.json\n+ |-i18n\n\n## Configuration file content\nahserver using json file format in its configuration, the following is a sample:\n```\n{\n\t\"databases\":{\n\t\t\"aiocfae\":{\n\t\t\t\"driver\":\"aiomysql\",\n\t\t\t\"async_mode\":true,\n\t\t\t\"coding\":\"utf8\",\n\t\t\t\"dbname\":\"cfae\",\n\t\t\t\"kwargs\":{\n\t\t\t\t\t\"user\":\"test\",\n\t\t\t\t\t\"db\":\"cfae\",\n\t\t\t\t\t\"password\":\"test123\",\n\t\t\t\t\t\"host\":\"localhost\"\n\t\t\t}\n\t\t},\n\t\t\"cfae\":{\n\t\t\t\"driver\":\"mysql.connector\",\n\t\t\t\"coding\":\"utf8\",\n\t\t\t\"dbname\":\"cfae\",\n\t\t\t\"kwargs\":{\n\t\t\t\t\t\"user\":\"test\",\n\t\t\t\t\t\"db\":\"cfae\",\n\t\t\t\t\t\"password\":\"test123\",\n\t\t\t\t\t\"host\":\"localhost\"\n\t\t\t}\n\t\t}\n\t},\n\t\"website\":{\n\t\t\"paths\":[\n\t\t\t[\"$[workdir]$/../usedpkgs/antd\",\"/antd\"],\n\t\t\t[\"$[workdir]$/../wolon\",\"\"]\n\t\t],\n\t\t\"host\":\"0.0.0.0\",\n\t\t\"port\":8080,\n\t\t\"coding\":\"utf-8\",\n\t\t\"ssl\":{\n\t\t\t\"crtfile\":\"$[workdir]$/conf/www.xxx.com.pem\",\n\t\t\t\"keyfile\":\"$[workdir]$/conf/www.xxx.com.key\"\n\t\t},\n\t\t\"indexes\":[\n\t\t\t\"index.html\",\n\t\t\t\"index.tmpl\",\n\t\t\t\"index.dspy\",\n\t\t\t\"index.md\"\n\t\t],\n\t\t\"visualcoding\":{\n\t\t\t\"default_root\":\"/samples/vc/test\",\n\t\t\t\"userroot\":{\n\t\t\t\t\"ymq\":\"/samples/vc/ymq\",\n\t\t\t\t\"root\":\"/samples/vc/root\"\n\t\t\t},\n\t\t\t\"jrjpath\":\"/samples/vc/default\"\n\t\t},\n\t\t\"processors\":[\n\t\t\t[\".xlsxds\",\"xlsxds\"],\n\t\t\t[\".sqlds\",\"sqlds\"],\n\t\t\t[\".tmpl.js\",\"tmpl\"],\n\t\t\t[\".tmpl.css\",\"tmpl\"],\n\t\t\t[\".html.tmpl\",\"tmpl\"],\n\t\t\t[\".tmpl\",\"tmpl\"],\n\t\t\t[\".dspy\",\"dspy\"],\n\t\t\t[\".md\",\"md\"]\n\t\t]\n\t},\n\t\"langMapping\":{\n\t\t\"zh-Hans-CN\":\"zh-cn\",\n\t\t\"zh-CN\":\"zh-cn\",\n\t\t\"en-us\":\"en\",\n\t\t\"en-US\":\"en\"\n\t}\n}\n```\n\n### database configuration\nthe ahserver using packages for database engines are:\n* oracle:cx_Oracle\n* mysql:mysql-connector\n* postgresql:psycopg2\n* sql server:pymssql\n\nhowever, you can change it, but must change the \"driver\" value the the package name in the database connection definition.\n\nin the databases section in config.json, you can define one or more database connection, and also, it support many database engine, just as ORACLE,mysql,postgreSQL.\ndefine a database connnect you need follow the following json format.\n\n* mysql or mariadb\n```\n \"metadb\":{\n \"driver\":\"mysql.connector\",\n \"coding\":\"utf8\",\n \"dbname\":\"sampledb\",\n \"kwargs\":{\n \"user\":\"user1\",\n \"db\":\"sampledb\",\n \"password\":\"user123\",\n \"host\":\"localhost\"\n }\n }\n```\nthe dbname and \"db\" should the same, which is the database name in mysql database\n* Oracle\n```\n\t\t\"db_ora\":{\n\t\t\t\"driver\":\"cx_Oracle\",\n\t\t\t\"coding\":\"utf8\",\n\t\t\t\"dbname\":sampledb\",\n\t\t\t\"kwargs\":{\n\t\t\t\t\"user\":\"user1\",\n\t\t\t\t\"host\":\"localhost\",\n\t\t\t\t\"dsn\":\"10.0.185.137:1521/SAMPLEDB\"\n\t\t\t}\n\t\t}\n```\n\n* SQL Server\n```\n \"db_mssql\":{\n \"driver\":\"pymssql\",\n \"coding\":\"utf8\",\n \"dbname\":\"sampledb\",\n \"kwargs\":{\n \"user\":\"user1\",\n \"database\":\"sampledb\",\n \"password\":\"user123\",\n \"server\":\"localhost\",\n \"port\":1433,\n \"charset\":\"utf8\"\n }\n }\n```\n* PostgreSQL\n```\n\t\t\"db_pg\":{\n\t\t\t\"driver\":\"psycopg2\",\n\t\t\t\"dbname\":\"testdb\",\n\t\t\t\"coding\":\"utf8\",\n\t\t\t\"kwargs\":{\n\t\t\t\t\"database\":\"testdb\",\n\t\t\t\t\"user\":\"postgres\",\n\t\t\t\t\"password\":\"pass123\",\n\t\t\t\t\"host\":\"127.0.0.1\",\n\t\t\t\t\"port\":\"5432\"\n\t\t\t}\n\t\t}\n```\n### https support\n\nIn config.json file, config.website.ssl need to set(see above)\n\n### website configuration\n#### paths\nahserver can serve its contents (static file, dynamic contents render by its processors) resided on difference folders on the server file system.\nahserver finds a content identified by http url in order the of the paths specified by \"paths\" lists inside \"website\" definition of config.json file\n#### processors\nall the prcessors ahserver using, must be listed here.\n#### host\nby defaualt, '0.0.0.0'\n#### port\nby default, 8080\n#### coding\nahserver recomments using 'utf-8'\n\n### langMapping\n\nthe browsers will send 'Accept-Language' are difference even if the same language. so ahserver using a \"langMapping\" definition to mapping multiple browser lang to same i18n file\n\n\n## international\n\nahserver using MiniI18N in appPublic modules in pyutils package to implements i18n support\n\nit will search translate text in ms* txt file in folder named by language name inside i18n folder in workdir folder, workdir is the folder where the ahserver program resided or identified by command line paraments.\n\n## performance\n\nTo be list here\n\n## environment for processors\n\nWhen coding in processors, ahserver provide some environment stuff for build apllication, there are modules, functions, classes and variables\n\n\n### modules:\n* time\n* datetime\n* random\n* json\n\n### functions:\n* configValue\n* isNone\n* int\n* str\n* float\n* type\n* str2date\n* str2datetime\n* curDatetime\n* uuid\n* runSQL\n* runSQLPaging\n* runSQLIterator\n* runSQLResultFields\n* getTables\n* getTableFields\n* getTablePrimaryKey\n* getTableForignKeys\n* folderInfo\n* abspath\n* request2ns\n* CRUD\n* data2xlsx\n* xlsxdata\n* openfile\n* i18n\n* i18nDict\n* absurl\n* abspath\n* request2ns\n\n### variables\n* resource\n* terminalType\n\n### classes\n* ArgsConvert\n\n\n", "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/yumoqing/ahserver", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "ahserver", "package_url": "https://pypi.org/project/ahserver/", "platform": "", "project_url": "https://pypi.org/project/ahserver/", "project_urls": { "Homepage": "https://github.com/yumoqing/ahserver" }, "release_url": "https://pypi.org/project/ahserver/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "ahserver", "version": "0.0.2" }, "last_serial": 5798095, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "7b284877932371f5de2bb2a22f55e8a4", "sha256": "5c2b30a4c7970050a001651fd6fa4ca5f728676841a83dca7d4dc65896c73a8f" }, "downloads": -1, "filename": "ahserver-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7b284877932371f5de2bb2a22f55e8a4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20403, "upload_time": "2019-09-08T02:45:22", "url": "https://files.pythonhosted.org/packages/b5/51/3049979cfb6ec3b823f7626985c05c10117e981335bafe1701bee1212fd0/ahserver-0.0.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7b284877932371f5de2bb2a22f55e8a4", "sha256": "5c2b30a4c7970050a001651fd6fa4ca5f728676841a83dca7d4dc65896c73a8f" }, "downloads": -1, "filename": "ahserver-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7b284877932371f5de2bb2a22f55e8a4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20403, "upload_time": "2019-09-08T02:45:22", "url": "https://files.pythonhosted.org/packages/b5/51/3049979cfb6ec3b823f7626985c05c10117e981335bafe1701bee1212fd0/ahserver-0.0.2-py3-none-any.whl" } ] }