File tree 4 files changed +399
-2
lines changed
4 files changed +399
-2
lines changed Original file line number Diff line number Diff line change 16
16
import subprocess
17
17
import sys
18
18
import time
19
+ import urllib
19
20
from functools import partial
20
21
from operator import getitem
21
22
from pathlib import Path
29
30
30
31
from ocrmypdf ._defaults import DEFAULT_ROTATE_PAGES_THRESHOLD
31
32
33
+
34
+ def get_host_url_with_port (port : int ) -> str :
35
+ """Get the host URL for the web service. Hacky."""
36
+ host_url = st .context .headers ["host" ]
37
+ try :
38
+ host , _streamlit_port = host_url .split (":" , maxsplit = 1 )
39
+ except ValueError :
40
+ host = host_url
41
+ return f"//{ host } :{ port } " # Use the same protocol
42
+
43
+
32
44
st .title ("OCRmyPDF Web Service" )
33
45
34
46
if not which ("ttyd" ):
218
230
ttyd_proc = subprocess .Popen (
219
231
ttyd_args + args , stdout = subprocess .PIPE , stderr = subprocess .PIPE
220
232
)
221
- iframe (src = f"http://localhost: { port } " , height = 400 )
233
+ iframe (src = get_host_url_with_port ( port ) , height = 400 )
222
234
223
235
while ttyd_proc .poll () is None :
224
236
ttyd_proc .poll ()
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
1
2
# SPDX-FileCopyrightText: 2025 James R. Barlow
2
3
# SPDX-License-Identifier: AGPL-3.0-or-later
3
4
Original file line number Diff line number Diff line change @@ -163,4 +163,5 @@ dev = [
163
163
" pymupdf>=1.24.14" ,
164
164
" streamlit-pdf-viewer>=0.0.19" ,
165
165
" streamlit>=1.40.2" ,
166
+ " ipykernel>=6.29.5" ,
166
167
]
You can’t perform that action at this time.
0 commit comments