mirror of
https://github.com/pyscript/pyscript.git
synced 2022-05-01 19:47:48 +03:00
Merge pull request #31 from anaconda/toga-spa
Add a Toga SPA rendering demo
This commit is contained in:
@@ -42,6 +42,9 @@
|
|||||||
WARNING: This examples takes a little longer to load. So be patient :)
|
WARNING: This examples takes a little longer to load. So be patient :)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h2 class="text-2xl font-bold text-blue-600"><a href="./toga/freedom.html" target=”_blank”>Freedom Units!</a></h2>
|
||||||
|
<p>A Toga application (a Fahrenheit to Celsius converter), rendered as a Single Page App</p>
|
||||||
|
|
||||||
<h2 class="text-2xl font-bold text-blue-600"><a href="./d3.html" target=”_blank”>Simple d3 visualization</a></h2>
|
<h2 class="text-2xl font-bold text-blue-600"><a href="./d3.html" target=”_blank”>Simple d3 visualization</a></h2>
|
||||||
<p>Minimal d3 demo demonstrating how to create a visualization</p>
|
<p>Minimal d3 demo demonstrating how to create a visualization</p>
|
||||||
|
|
||||||
|
|||||||
54
pyscriptjs/examples/toga/freedom.html
Normal file
54
pyscriptjs/examples/toga/freedom.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="icon" type="image/png" href="./static/logo-32.png"/>
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
|
||||||
|
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="./static/toga.css">
|
||||||
|
|
||||||
|
<script defer src="../build/pyscript.js"></script>
|
||||||
|
|
||||||
|
<title>Loading...</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="toga-placeholder">Loading...</div>
|
||||||
|
|
||||||
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
|
||||||
|
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
|
||||||
|
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
|
||||||
|
integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
|
||||||
|
crossorigin="anonymous">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
<py-script>
|
||||||
|
import asyncio
|
||||||
|
import micropip
|
||||||
|
|
||||||
|
await micropip.install([
|
||||||
|
'./static/wheels/travertino-0.1.3-py3-none-any.whl',
|
||||||
|
'./static/wheels/toga_core-0.3.0.dev33-py3-none-any.whl',
|
||||||
|
'./static/wheels/toga_web-0.3.0.dev33-py3-none-any.whl',
|
||||||
|
'./static/wheels/freedom-0.0.1-py3-none-any.whl',
|
||||||
|
])
|
||||||
|
|
||||||
|
from toga_web.dom import handle as dom_handle
|
||||||
|
|
||||||
|
from freedom.__main__ import main
|
||||||
|
|
||||||
|
app = main().main_loop(spa=True)
|
||||||
|
|
||||||
|
</py-script>
|
||||||
|
</html>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mkdir -p ../server/static/wheels
|
mkdir -p ../static/wheels
|
||||||
cd src
|
cd src
|
||||||
unzip ../base-wheel.zip
|
unzip ../base-wheel.zip
|
||||||
zip ../../server/static/wheels/freedom-0.0.1-py3-none-any.whl -r freedom*
|
zip ../../static/wheels/freedom-0.0.1-py3-none-any.whl -r freedom*
|
||||||
rm -rf freedom-0.0.1.dist-info
|
rm -rf freedom-0.0.1.dist-info
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from toga_flask import TogaApp
|
|||||||
|
|
||||||
from freedom import app as freedom
|
from freedom import app as freedom
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__, static_folder='../static')
|
||||||
|
|
||||||
app.add_url_rule('/', view_func=TogaApp.as_view("foo", app_module=freedom))
|
app.add_url_rule('/', view_func=TogaApp.as_view("foo", app_module=freedom))
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user