-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
32 lines (28 loc) · 944 Bytes
/
main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<style>
h1 {
font-size: 20px;
color: green;
text-transform: uppercase;
text-align: center;
margin: 0 0 35px 0;
text-shadow: 0px 1px 0px #f2f2f2;
}
</style>
</head>
<body style='font-size: 20px;'>
<h1>PyScript - HTTP Requests pyfetch</h1>
<div id="request_output"></div>
<py-script>
from pyodide.http import pyfetch
import asyncio
response = await pyfetch(url="https://jsonplaceholder.typicode.com/todos/1", method="GET")
output = f"GET request=> status:{response.status}, json:{await response.json()}"
pyscript.write('request_output', output)
</py-script>
</body>
</html>