question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem loading local html

See original GitHub issue

Specification

  • Platform: macOS
  • Version: 10.13.6

Description

Hi, I’ve just started using pywebview and am having trouble loading/linking local html/css/js files. webview.create_window('Test', 'assets/index.html') only shows a white screen whereas

def load_html():
    with open('assets/index.html') as html:
        webview.load_html(str(html.read()))


if __name__ == '__main__':
    t = threading.Thread(target=load_html)
    t.start()
    webview.create_window('Test')

doesn’t load the image or stylesheet referenced in the HTML:

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="style.css">
  <meta charset="utf-8"/>
</head>
<body bgcolor="#0099ff">
	<div align="center">
            <img src="images/logo.jpg">
            <h1>TEST</h1>
        </div>
</body>
</html>

I’m probably missing something very obvious, any help is appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
shivaprsdcommented, Nov 16, 2018

Or pass debug=True as an argument to create_window() and on the white screen try Control Click -> Inspect Element to inspect the webview.

1reaction
shivaprsdcommented, Nov 20, 2018

Great! Thanks for helping figure it out. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why isn't my local index.HTML file loading in my browser?
You have your website or pages set to 'noindex '. One of the first things I look for when a page or website...
Read more >
Local HTML file not loading CSS file in browser - Stack Overflow
Local HTML file not loading CSS file in browser - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational ...
Read more >
Webview load local html - Visual Studio Feedback
i use web.Navigate(new Uri(“ms-appx:///sample.html”)); load local html; Report an error:System.Exception: “Aborted operation (Exception from HRESULT: ...
Read more >
CSS not loading on local html file - Reddit
I think it is related to the css path you providing on that site. When you are doing it on your local machine...
Read more >
Load Local HTML File or URL in React Native using react ...
You have to make 2 copies of the HTML file and have to put them on a different location for Android and IOS....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found