pythonhttphttpclienturllib2if-modified-since

Sync local file with HTTP server location (in Python)


I have an HTTP server which host some large file and have python clients (GUI apps) which download it.
I want the clients to download the file only when needed, but have an up-to-date file on each run.

I thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python?

Can someone suggest an alternative, easy, way to achieve my goal?


Solution

  • It seems to me the easiest solution is hosting the file in mercurial and using mercurial api to find the file's hash, downloading the file if the hash has changed. Calculating the hash can be done as the answer to this question; for downloading the file urllib will be enough.