-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathload_url.py
More file actions
52 lines (43 loc) · 1.07 KB
/
load_url.py
File metadata and controls
52 lines (43 loc) · 1.07 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "justbe-webview",
# ]
#
# [tool.uv.sources]
# justbe-webview = { path = "../" }
# ///
import asyncio
from justbe_webview import (
WebView,
Options,
ContentUrl,
Notification,
)
async def main():
print("Creating webview")
config = Options(
title="Load Url Example",
load=ContentUrl(
url="https://example.com",
headers={
"Content-Type": "text/html",
},
),
userAgent="curl/7.81.0",
devtools=True,
)
async with WebView(config) as webview:
async def handle_start(event: Notification):
await webview.open_devtools()
await asyncio.sleep(2) # Sleep for 2 seconds
await webview.load_url(
"https://val.town/",
headers={
"Content-Type": "text/html",
},
)
webview.on("started", handle_start)
print("Webview closed")
if __name__ == "__main__":
asyncio.run(main())