Forums

Can PythonAnywhere call APIs from APScheduler?

I deployed Flask app on PythonAnywhere but an api that calls an external APScheduler api /scheduler/jobs fails because it keeps loading endlessly. Everything worked fine in local host.

I added CORS to my app to allow pythonanywhere's host name. I can curl in pythonanywhere's bash: curl -X GET http://<username>.pythonanywhere.com/scheduler/jobs and also do the same in Postman ```python @api_bp.route('/jobs_details', methods=['GET']) def get_jobs_details(): jobs_data = fetch_scheduler_jobs(request)

def fetch_scheduler_jobs(request): # Fetch from builtin API base_url = request.host_url.rstrip('/') url = f"{base_url}/scheduler/jobs" headers = dict(request.headers) # response = requests.get(url, headers=headers) return headers ```

I checked my code and everything worked until I uncomment requests.get(), it fails.

Take a look at https://help.pythonanywhere.com/pages/AsyncInWebApps/