Unable to config pywebview caching directory

Viewed 224

I need to create a desktop app that access a webpage and also need to be able to control it's caching location (such as images of this webpage) for offline usage.

Just like any browser already does? Yes, but I cannot use any browser like Firefox, Chrome, Chromium... Unless it's in the form of a DLL or something similar (the browser itself cannot be installed)

I already found how to delete cache and how to disable caching, just need to alter the caching directory.

take this code as example:

import webview
webview.create_window('Hello world', 'https://pywebview.flowrl.com/hello')
webview.start() 

Let's suppose it downloads a image and stores it in cache. I need to be able to open multiple instances of the application, each with it's separate caching directory.

Anyone knows how to change the caching directory? something like:

webview.cache.setDir("c://User/user-2")

I'm alright with the usage of other libs such ad flask or bottle (or any other really)

Also, the solution needs to work for both Widows and Ubuntu

Thanks in advance.

1 Answers

As you mentioned, There are third-party libraries you can use. Flask for instance works very well with pywebview. the webview.create_window method accepts an HTTP server(In this case flask). With flask you can then use the flask cache module to specify a directory to store the files You can check the docs on flask caching to see other possibilities

https://flask-caching.readthedocs.io/en/latest/

Related