dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
17.3k stars 965 forks source link

Can't run changedetection.io on windows after updating to version 0.39. #194

Closed tienquanutc closed 2 years ago

tienquanutc commented 3 years ago

On Windows operating system, changedetection crashes after updating to version 0.39. It gives the error ValueError: urls must start with a leading slash right on launch. Seems to be caused by the code below

#changedetectionio/__init__: line 46
# Needs to be set this way because we also build and publish via pip
base_path = os.path.dirname(os.path.realpath(__file__))
app = Flask(__name__,
             static_url_path="{}/static".format(base_path),
             template_folder="{}/templates".format(base_path))

On windows, base_path starts with drive letters C, D, or E. Flask does not accept such path as static_url_path. On Linux, everything works fine. I have no experience in Python to create a PR

dgtlmoon commented 3 years ago

Sorry we dont support native windows yet... but sometime soon yes

dgtlmoon commented 3 years ago

I'm open to PRs tho

dgtlmoon commented 3 years ago

When I find a windows VM machine that works i'll take a look

tienquanutc commented 3 years ago

Static files have been handled by the route @app.route("/static/<string:group>/<string:filename>", methods=['GET']). I think removing static_url_path param doesn't affect changedetection working

dgtlmoon commented 3 years ago

I see that paths are also absolute, and they probably dont need to be (atleast by default)

 "1629464180": "C:\\Users\\dev\\Desktop\\changedetection.io\\datastore/b122be89-bd12-49f8-829e-963811ca950e/38b1ec7c-3813-4d83-ae13-34dd977823fa.stripped.txt",
"1629464201": "C:\\Users\\dev\\Desktop\\changedetection.io\\datastore/b122be89-bd12-49f8-829e-963811ca950e/0b82a306-6491-41a9-9040-80e75b509082.stripped.txt"

.. I need a windows VM :(

Lisawitz commented 3 years ago

I had this problem too. this thread has one part of a solution by user Susensio, basically you'll have to change blueprints.py line 250: self.add_url_rule( '/static' + '/<path:filename>', view_func=self.send_static_file, endpoint="static", ... and in app.py line 602: self.add_url_rule( '/static' + '/<path:filename>', endpoint="static", ...

and I think you'll also have to be using python 3.8 to avoid a separate issue. this means you might have to do something like "py -3.8 changedetection.py -d C:\Users\Owner\Desktop\changedetection -p 5000" to run it. I just wanted to include that in case you run into it too

dgtlmoon commented 3 years ago

we dont use blueprints.py hmm

Lisawitz commented 3 years ago

oh yeah, I tested it and it does seem like you only need to make that small change to app.py. blueprints.py doesn't need to be changed if it's not used.

dgtlmoon commented 2 years ago

there was an upgrade to flask recently, I think it may have solved this issue, can you retest?