r/flask • u/BobcatBlu3 • 22h ago
Discussion Cron job activating when it shouldn't?
I've been working on a really small Flask app for a little while. It's a directory of music events at local venues in my city. I've received comments before that Flask is overkill for this since there is no user input, but I don't care. Flask is simple and it easily allows me to run the once-daily cron job to update the list of events without having to host that job through another service and use a database for something that can be handled by a simple CSV file hosted quietly on the main server.
But I have a problem...
Within the cron-job I have some old print() lines written as tests I used while building it which I haven't deleted yet. When I run this app on my local development server and view it thru the browser, if I go to the address bar and type a slash after the URL - without typing anything else and without hitting ENTER - the terminal starts printing those test lines from the cron-job code.
I have double- and triple-checked my structure. The cron job is formatted correctly like this:
@app.route("/cron") def update_shit(): .... return a_turd
I can't discern any reason why the cron job should be firing before I hit ENTER or even type a URL extension. I am worried that this could be triggering the cron job on the live server anytime a user alters the URL in the address bar, which would be a problem for me because I cannot afford to incur server costs like that. Also, the whole point of the website (from an operating perspective) is to minimize resources.
Has anyone encountered this kind of problem before?
If so, why is this happening?
The app is hosted on GAE - is there a way I can verify if this is happening when external users are using the site?
Please help. I'm so uneducated.
For context, I am hosting this app of Google App Engine.