# webz
```
简单的web服务器框架,实现的是配置文件的读取和调用,内部调用web.py
注:代码实现了url映射和查找,查找方式是for循环遍历列表,url映射配置多了的话循环显然不是好方法,相关代码在
configz.ConfigWeb.deal和config.ConfigWeb.deal
可以自行修改
demo在demo文件夹中,两种配置方式,分别运行:
python run.py
python runz.py
推荐runz.py的配置方式
为了本人自己使用方便以及利用浏览器缓存减少http请求,把bootstrap、jquery.js和vue.js放进文件夹了,可以不使用或者替换掉,另外有两脚本文件base.js和utils.js,分装了一些方法:
json调用:
$.json(url, data, success=(rst)=>{}, error=(rst)=>{})
$.upload(...)
$.submit(...) //这个没测试
$.get(url, success=(rst)=>{}, error=(rst)=>{})
页面跳转(带数据)
_.jump(url, data)
新页面通过以下方法获取数据:
_.data()
页面回跳(和左上角后退键一个功能,不过可以加回跳参数):
_.back(backData=null)
原页面还是通过_.data()获取初始化时的原数据,也可以通过_.backData()获取回跳时设置的数据
通过js代码引入js文件库:
addScript(url)
通过js代码引入css文件库:
addStyle(url)
vue相关:
组件:
component(url, id=null)
实际是把url对应的页面嵌入当前页面
页面vue创建:
newVue({
data(){return {...}},
mounted(){...},
methods:{...}
})
相关使用参考demo/test1.html
要使用这个工具类,需要把/webz/js映射成webz.js,并在页面引入脚本:
<script src="/webz/js/base.js"></script>
<script src="/webz/js/packs.js"></script>
或者
<script src="/webz/js/base.js"></script>
<script src="jquery路径"></script>
<script src="vue路径"></script>
<script src="/webz/js/utiils.js"></script>
任意一个运行后,尝试访问网址:
http://127.0.0.1:8080/page/test1.html
http://127.0.0.1:8080/func/abc?d=e&f=g
```
Raw data
{
"_id": null,
"home_page": "https://github.com/buildCodeZ/webz",
"name": "webz",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "webz",
"author": "Zzz",
"author_email": "1309458652@qq.com",
"download_url": "https://files.pythonhosted.org/packages/a9/83/55b044d3c763bd0825bf11c6e675c43144b58fabb4d92e61521f1199c65d/webz-0.0.9.tar.gz",
"platform": "any",
"description": "# webz\r\n```\r\n\u7b80\u5355\u7684web\u670d\u52a1\u5668\u6846\u67b6\uff0c\u5b9e\u73b0\u7684\u662f\u914d\u7f6e\u6587\u4ef6\u7684\u8bfb\u53d6\u548c\u8c03\u7528\uff0c\u5185\u90e8\u8c03\u7528web.py\r\n\r\n\u6ce8\uff1a\u4ee3\u7801\u5b9e\u73b0\u4e86url\u6620\u5c04\u548c\u67e5\u627e\uff0c\u67e5\u627e\u65b9\u5f0f\u662ffor\u5faa\u73af\u904d\u5386\u5217\u8868\uff0curl\u6620\u5c04\u914d\u7f6e\u591a\u4e86\u7684\u8bdd\u5faa\u73af\u663e\u7136\u4e0d\u662f\u597d\u65b9\u6cd5\uff0c\u76f8\u5173\u4ee3\u7801\u5728\r\nconfigz.ConfigWeb.deal\u548cconfig.ConfigWeb.deal\r\n\u53ef\u4ee5\u81ea\u884c\u4fee\u6539\r\n\r\ndemo\u5728demo\u6587\u4ef6\u5939\u4e2d\uff0c\u4e24\u79cd\u914d\u7f6e\u65b9\u5f0f\uff0c\u5206\u522b\u8fd0\u884c\uff1a\r\npython run.py\r\npython runz.py\r\n\u63a8\u8350runz.py\u7684\u914d\u7f6e\u65b9\u5f0f\r\n\r\n\u4e3a\u4e86\u672c\u4eba\u81ea\u5df1\u4f7f\u7528\u65b9\u4fbf\u4ee5\u53ca\u5229\u7528\u6d4f\u89c8\u5668\u7f13\u5b58\u51cf\u5c11http\u8bf7\u6c42\uff0c\u628abootstrap\u3001jquery.js\u548cvue.js\u653e\u8fdb\u6587\u4ef6\u5939\u4e86\uff0c\u53ef\u4ee5\u4e0d\u4f7f\u7528\u6216\u8005\u66ff\u6362\u6389\uff0c\u53e6\u5916\u6709\u4e24\u811a\u672c\u6587\u4ef6base.js\u548cutils.js\uff0c\u5206\u88c5\u4e86\u4e00\u4e9b\u65b9\u6cd5:\r\n json\u8c03\u7528:\r\n $.json(url, data, success=(rst)=>{}, error=(rst)=>{})\r\n $.upload(...)\r\n $.submit(...) //\u8fd9\u4e2a\u6ca1\u6d4b\u8bd5\r\n $.get(url, success=(rst)=>{}, error=(rst)=>{})\r\n \u9875\u9762\u8df3\u8f6c\uff08\u5e26\u6570\u636e\uff09\r\n _.jump(url, data)\r\n \u65b0\u9875\u9762\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u83b7\u53d6\u6570\u636e\uff1a\r\n _.data()\r\n \u9875\u9762\u56de\u8df3\uff08\u548c\u5de6\u4e0a\u89d2\u540e\u9000\u952e\u4e00\u4e2a\u529f\u80fd\uff0c\u4e0d\u8fc7\u53ef\u4ee5\u52a0\u56de\u8df3\u53c2\u6570\uff09:\r\n _.back(backData=null)\r\n \u539f\u9875\u9762\u8fd8\u662f\u901a\u8fc7_.data()\u83b7\u53d6\u521d\u59cb\u5316\u65f6\u7684\u539f\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7_.backData()\u83b7\u53d6\u56de\u8df3\u65f6\u8bbe\u7f6e\u7684\u6570\u636e\r\n\r\n \u901a\u8fc7js\u4ee3\u7801\u5f15\u5165js\u6587\u4ef6\u5e93:\r\n addScript(url)\r\n \u901a\u8fc7js\u4ee3\u7801\u5f15\u5165css\u6587\u4ef6\u5e93:\r\n addStyle(url)\r\n\r\n vue\u76f8\u5173\uff1a\r\n \u7ec4\u4ef6:\r\n component(url, id=null)\r\n \u5b9e\u9645\u662f\u628aurl\u5bf9\u5e94\u7684\u9875\u9762\u5d4c\u5165\u5f53\u524d\u9875\u9762\r\n\r\n \u9875\u9762vue\u521b\u5efa\uff1a\r\n newVue({\r\n data(){return {...}},\r\n mounted(){...},\r\n methods:{...}\r\n })\r\n\r\n \u76f8\u5173\u4f7f\u7528\u53c2\u8003demo/test1.html\r\n\r\n \u8981\u4f7f\u7528\u8fd9\u4e2a\u5de5\u5177\u7c7b\uff0c\u9700\u8981\u628a/webz/js\u6620\u5c04\u6210webz.js\uff0c\u5e76\u5728\u9875\u9762\u5f15\u5165\u811a\u672c:\r\n <script src=\"/webz/js/base.js\"></script>\r\n <script src=\"/webz/js/packs.js\"></script>\r\n \u6216\u8005\r\n <script src=\"/webz/js/base.js\"></script>\r\n <script src=\"jquery\u8def\u5f84\"></script>\r\n <script src=\"vue\u8def\u5f84\"></script>\r\n <script src=\"/webz/js/utiils.js\"></script>\r\n\r\n\u4efb\u610f\u4e00\u4e2a\u8fd0\u884c\u540e\uff0c\u5c1d\u8bd5\u8bbf\u95ee\u7f51\u5740\uff1a\r\nhttp://127.0.0.1:8080/page/test1.html\r\nhttp://127.0.0.1:8080/func/abc?d=e&f=g\r\n\r\n```\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "\u7b80\u5355\u7684web\u670d\u52a1\u5668\u6846\u67b6\uff0c\u5b9e\u73b0\u7684\u662f\u914d\u7f6e\u6587\u4ef6\u7684\u8bfb\u53d6\u548c\u8c03\u7528\uff0c\u5185\u90e8\u8c03\u7528web.py",
"version": "0.0.9",
"split_keywords": [
"webz"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a98355b044d3c763bd0825bf11c6e675c43144b58fabb4d92e61521f1199c65d",
"md5": "1d9192d47e42b04fa25556b7838ef202",
"sha256": "35d18a151fe9f911c305d94952d3d75e9e84b418abe15eb5e1d975c22f6bd23b"
},
"downloads": -1,
"filename": "webz-0.0.9.tar.gz",
"has_sig": false,
"md5_digest": "1d9192d47e42b04fa25556b7838ef202",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 137739,
"upload_time": "2023-03-12T14:58:26",
"upload_time_iso_8601": "2023-03-12T14:58:26.729086Z",
"url": "https://files.pythonhosted.org/packages/a9/83/55b044d3c763bd0825bf11c6e675c43144b58fabb4d92e61521f1199c65d/webz-0.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-12 14:58:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "buildCodeZ",
"github_project": "webz",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "webz"
}