Created
May 10, 2022 15:46
-
-
Save manatlan/95cde7869ee04582bc8d92fc832cfcca to your computer and use it in GitHub Desktop.
An example of fileupload with HTAG in PYSCRIPT
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <style>py-script,py-env {display: none}</style> | |
| <script defer src="https://pyscript.net/alpha/pyscript.js"></script> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <py-env> | |
| - htag==0.4.7 | |
| - htbulma | |
| </py-env> | |
| </head> | |
| <body> loading pyscript ;-) | |
| <py-script> | |
| from htag import Tag | |
| import htbulma as b | |
| class Main(Tag.body): | |
| statics = Tag.title("My Title") | |
| def init(self): | |
| self <= b.FileUpload( self.handleFile ) | |
| def handleFile(self,name: str,content: bytes): | |
| self <= Tag.div( | |
| Tag.h1("UPLOADED %s" % name) + Tag.pre(content) | |
| ) | |
| ############################################################################### | |
| from htag.runners import PyScript | |
| from js import window | |
| PyScript( Main ).run( window ) | |
| </py-script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment