Skip to content

Instantly share code, notes, and snippets.

@manatlan
Created May 10, 2022 15:46
Show Gist options
  • Select an option

  • Save manatlan/95cde7869ee04582bc8d92fc832cfcca to your computer and use it in GitHub Desktop.

Select an option

Save manatlan/95cde7869ee04582bc8d92fc832cfcca to your computer and use it in GitHub Desktop.
An example of fileupload with HTAG in PYSCRIPT
<!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