Last active
March 20, 2023 10:58
-
-
Save AWeirdDev/a32bfb1990ef6c0b819d7b156149a241 to your computer and use it in GitHub Desktop.
rapiz-dl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rapiz.app import API, APIContext | |
| import time | |
| api = API() | |
| @api('/api/user', methods=['GET', 'POST']) | |
| def user(res: APIContext): | |
| return { | |
| "name": "John Cena", | |
| "timestamp": str(time.time()) | |
| } | |
| EXPORT = api # !important |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Run this file to start the server. | |
| Nothing else required. | |
| """ | |
| from rapiz.core import Rapiz | |
| server = Rapiz() | |
| server.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rapiz.app import Middleware, MiddlewareContext | |
| mdw = Middleware() | |
| @mdw("*") # or "all" | |
| def index(res: MiddlewareContext): | |
| print("Wow, a new visitor!") | |
| EXPORT = mdw # !important |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # route: / | |
| from rapiz.app import Writer | |
| writer = Writer() | |
| html = writer.html | |
| markdown = writer.markdown | |
| writer.write( | |
| ( | |
| markdown("# Welcome to my website!"), | |
| html("button", onClick="times += 1") << "Click me!", | |
| html("p") << "You clicked %times% times!" | |
| ) | |
| ) | |
| EXPORT = writer # !important |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "beta", | |
| "goodLuck": true, | |
| "backend": { | |
| "host": "0.0.0.0", | |
| "port": 8080, | |
| "entrypoint": "main.py", | |
| "manuallySetStaticFiles": false, | |
| "startUpScripts": [ | |
| "echo Starting..." | |
| ] | |
| }, | |
| "frontend": { | |
| "pages": "pages", | |
| "middleware": "middleware.py", | |
| "api": "api" | |
| }, | |
| "commands": { | |
| "new": false | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment