Add /typst web form

This commit is contained in:
Joscha 2024-06-01 19:47:33 +02:00
parent 0345a80349
commit ede8621867
3 changed files with 23 additions and 1 deletions

View file

@ -34,7 +34,7 @@ pub async fn run(tx: mpsc::Sender<Command>, addr: String) -> anyhow::Result<()>
.route("/photo", post(post_photo).fallback(get_static_file)) .route("/photo", post(post_photo).fallback(get_static_file))
.route("/text", post(post_text)) .route("/text", post(post_text))
.route("/tictactoe", post(post_tictactoe)) .route("/tictactoe", post(post_tictactoe))
.route("/typst", post(post_typst)) .route("/typst", post(post_typst).fallback(get_static_file))
.fallback(get(get_static_file)) .fallback(get(get_static_file))
.layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB .layer(DefaultBodyLimit::max(32 * 1024 * 1024)) // 32 MiB
.with_state(Server { tx }); .with_state(Server { tx });

View file

@ -10,6 +10,7 @@
<ul> <ul>
<li><a href="image">Upload an image</a></li> <li><a href="image">Upload an image</a></li>
<li><a href="photo">Take a photo</a></li> <li><a href="photo">Take a photo</a></li>
<li><a href="typst">Print typst</a></li>
<li><a href="egg">Osterei</a></li> <li><a href="egg">Osterei</a></li>
</ul> </ul>
</body> </body>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>TP: Typst</title>
</head>
<body>
<h1>Print typst code</h1>
<form method="post">
<textarea name="source" rows="24" cols="100">
Hi from Typst!
$
sum_(i=1)^n i = integral_(i=0)^n i + n/2
$</textarea
>
<br />
<button>Print!</button>
</form>
</body>
</html>