Skip to content

[SOLVED] Selective treatment of resources #1459

Answered by sjehuda
sjehuda asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your help at #1460 (comment)

This is the final code which defines the activity of pywebview to a single "origin".

Python

import webview
import subprocess
import sys

class HtmlView:
    def __init__(self, url_instance):
        self.url_instance = url_instance

    def regulator(self, uri):
        # Check if the URL is not from url_instance
        if not uri.startswith(self.url_instance):
            try:
                # Open the link using xdg-open
                subprocess.run(['xdg-open', uri], check=True)
            except subprocess.CalledProcessError as e:
                print(f"Failed to open URL: {uri}. Error: {e}")
        else:
            # If it is from ur…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@sjehuda
Comment options

@r0x0r
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by sjehuda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants