{"id":21569400,"url":"https://github.com/aweirddev/wzg","last_synced_at":"2026-01-04T11:35:50.418Z","repository":{"id":162941984,"uuid":"603375838","full_name":"AWeirdDev/wzg","owner":"AWeirdDev","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-18T15:35:51.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T12:32:29.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AWeirdDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-18T10:18:00.000Z","updated_at":"2023-02-18T10:18:00.000Z","dependencies_parsed_at":"2024-04-28T12:44:03.546Z","dependency_job_id":"3bd22a24-ca99-4d8d-aa92-19dfb6511e84","html_url":"https://github.com/AWeirdDev/wzg","commit_stats":null,"previous_names":["aweirddev/wzg"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fwzg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fwzg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fwzg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWeirdDev%2Fwzg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AWeirdDev","download_url":"https://codeload.github.com/AWeirdDev/wzg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244166677,"owners_count":20409178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T11:09:25.369Z","updated_at":"2026-01-04T11:35:50.384Z","avatar_url":"https://github.com/AWeirdDev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# wzg\nSimple tool for creating simple applications.\n\n## Simple Routing\nTo create a light application, we recommend you use our **`Wzg.FileTreeRouting`**, designed for route mapping by file tree.\n\n```py\n# Files\n.\n└── 🏠 src/\n    ├── 📂 routes/\n    │   ├── 🚀 index.html\n    │   └── 🚀 test.html\n    └── 📦 main.py\n```\n\n```py\nfrom wzg import Wzg\n\napp = Wzg.FileTreeRouting(\n  tree=\"routes\" # *optional*, \"routes\" in default\n)\n\napp() # start the application\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eRenaming Routes\u003c/b\u003e\u003c/summary\u003e\n  \u003cp\u003e\n\nBy default, **`FileTreeRouting`** automatically sets the route to the HTML file name. (Though for `index.html`, it's set to the base route `/`)\n\nWe can simply rename the routes by specifying them in `rename`:\n\n```py\napp = Wzg.FileTreeRouting(\n  tree=\"routes\",\n  rename={\n    \"test\": \"hello/1\"\n  }\n)\n```\n\n\u003csub\u003e\u003ci\u003eThis is an example of renaming the \"/test\" path to \"/hello/1\". \u003c/i\u003e\u003c/sub\u003e\n\nGenerally, this replaces the original route (`/test`) from the file name (`test.html`) to a user-defined route (`/hello/1`).\n\nIn addition, you could also modify the routes using decorators:\n\n```py\napp = Wzg.FileTreeRouting(\n  tree=\"routes\",\n  rename=\"custom\" # Use the \"custom\" keyword\n)\n\n@app.route('/hello/1')\ndef hello_route(req):\n  return app['test'] # return the \"test.html\" file\n```\n\u003csub\u003e\u003ci\u003eThis is an advanced example of modifying the routes using decorators\u003c/i\u003e\u003c/sub\u003e\n\n  \u003c/p\u003e\n\u003c/details\u003e\n\n## Parsed\nIf you prefer React + Python, here it is! \n\nNote that the file extension is NOT for Cython, this generally indicates \"**Py**thon E**x**tension\".\n\n```py\n# Files\n.\n└── 🏠 src/\n    ├── 📂 components/\n    │   └── ✨ App.pyx\n    ├── 🚀 index.html\n    └── 📦 main.py\n```\n\nLet's give it a shot by editing **`components/App.pyx**`:\n```pyx\n# App.pyx\n\n$use strict\n\nfrom uuid import uuid4\n\n# create the component\ndef App(children):\n  return (\n    \u003cdiv id={str(uuid4())}\u003e\n      {children}\n    \u003c/div\u003e\n  )\n\n# export the component as default\n$export default App\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eHow does it look like after parsing?\u003c/b\u003e\u003c/summary\u003e\n  \u003cp\u003e\n\nAfter parsing the `pyx` (Python Extension) file, it should output a file exactly named `App.py` (without the 'x').\n\nHere's how it looks like:\n\n```py\nfrom wzg import component as _0e80d2c35a33\nfrom wzg import html as _e13b9bb4b6f3\n\n# _USER_IMPORT\nfrom uuid import uuid4\n\n@_0e80d2c35a33\ndef App(ctx):\n  return ( #BEGIN-COMPONENT\n    _e13b9bb4b6f3(\"div\", **{\"id\":str(uuid4())}) \u003c\u003c ctx.children,\n  ) #END-OF-COMPONENT\n\nEXPORTS = {\"default\": App}\n\n# mappingResult::{\"result\": {\"foundErrors\":0,\"userImports\":1,\"ellasped\":\"300ms\"}}\n# mappingKeyIsValid::true\n# mappingKey::MWE5ODM4NzctZDg4NS00NTA2LTllZjgtMThhOWFlYjg0NGQ0MjQ2ZDE4YWEtOGU0MS00YzdmLTljMTUtZjNlMzFkZTJiYjYw\n```\n\n...along with another file named \"\\_\\_init\\_\\_.py\":\n\n```py\nfrom .App import EXPORTS as _App_EXPORTS\n\nEXPORTS = {\"App\": _App_EXPORTS}\n```\n\n  \u003c/p\u003e\n\u003c/details\u003e\n\nNice, now we have a working component.\n\nNext up, let's jump right back to the **`main.pyx`** file:\n\n```pyx\nfrom wzg import Wzg\n\n# with dollar sign as prefix,\n# it's treated as a file instead of a package.\nfrom $components.App import App\n\napp = Wzg(project=True) # project mode\n\napp.render(\n  (\n    \u003cApp\u003e\n      Good Morning!\n    \u003c/App\u003e\n  ),\n  root=\"#the-root\"\n)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eHow does it look like after parsing?\u003c/b\u003e\u003c/summary\u003e\n  \u003cp\u003e\n\nHere's the output file content (main.py):\n\n```py\nfrom components import EXPORTS\n# CONST::EXPORTS\nApp = EXPORTS['App']['default']\n\n# _USER_IMPORT\nfrom wzg import Wzg\n\napp = Wzg(project=True) # project mode\n\napp.render(\n  ( #BEGIN-COMPONENT\n    App() \u003c\u003c \"Good Morning!\"\n  ), #END-OF-COMPONENT\n  root=\"#the-root\"\n)\n# mappingResult::{\"result\": {\"foundErrors\":0,\"userImports\":2,\"ellasped\":\"300ms\"}}\n# mappingKeyIsValid::true\n# mappingKey::ZTNiNGYwNzAtMmU5NC00Yzk4LTliOTktY2VlY2E1NzFkNWE5NGQ4NzUxYmUtMTZhNy00MDljLThkZjMtMTIwZjMyNTBhZWVk\n```\n\nMoreover, another JSX file appears (but in a random name):\n\n```jsx\n// Code generated with Wzg\n\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst WzgApplication = () =\u003e ( // start\n  \u003cdiv id=\"b4f92452-6d04-4e0a-a082-e593bbe399f8\"\u003eGood Morning!\u003c/div\u003e\n) // end\n\nconst root = document.querySelector('#the-root');\n\nReactDOM.createRoot(root).render(\n  \u003cReact.StrictMode\u003e\n    \u003cWzgApplication /\u003e\n  \u003c/React.StrictMode\u003e\n)\n```\n\n  \u003c/p\u003e\n\u003c/details\u003e\n\nFor the `index.html` file, the script import is required as follow:\n\n```html\n\u003c!DOCTYPE HTML\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eGood Morning Website\u003c/title\u003e\n    \u003c!-- Add the following keyword in order to work! --\u003e\n    \n    {DEV_MODE}\n    \n    \u003c!-- DEV_MODE for development; PR_MODE for production --\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"the-root\"\u003e\u003c/div\u003e\n    \u003c!-- Just use the keyword, then wzg will do it for you! --\u003e\n    {SCRIPT}\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cb\u003eConverted File\u003c/b\u003e\u003c/summary\u003e\n  \u003cp\u003e\n\nHere's the converted (parsed) HTML file:\n\n```html\n\u003c!DOCTYPE HTML\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eGood Morning Website\u003c/title\u003e\n    \u003c!-- Add the following keyword in order to work! --\u003e\n    \n    \u003cscript src=\"https://unpkg.com/react@18/umd/react.development.js\" crossorigin\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/react-dom@18/umd/react-dom.development.js\" crossorigin\u003e\u003c/script\u003e\n    \u003cscript src=\"https://unpkg.com/babel-standalone@6/babel.min.js\"\u003e\u003c/script\u003e\n    \n    \u003c!-- DEV_MODE for development; PR_MODE for production --\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"the-root\"\u003e\u003c/div\u003e\n    \u003c!-- Just use the keyword, then wzg will do it for you! --\u003e\n    \u003cscript type=\"text/babel\" src=\"523e03baa35f.jsx\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n  \u003c/p\u003e\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweirddev%2Fwzg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faweirddev%2Fwzg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faweirddev%2Fwzg/lists"}