Reputation: 2071
I am trying to write simple python function and want to deploy it using GCF(Google Cloud Function).
def check_refresh_date(request):
import requests
requestData = requests.get(
"https://coronavirus.data.gov.uk/downloads/json/coronavirus-cases_latest.json")
return requestData
requirement.txt looks like:
certifi==2020.6.20
chardet==3.0.4
idna==2.10
numpy==1.19.0
pandas==1.0.5
python-dateutil==2.8.1
pytz==2020.1
requests==2.24.0
six==1.15.0
urllib3==1.25.9
wincertstore==0.2
When I trigger this function it returns
"Error: could not handle the request"
on browser. In logs it is showing
"Function execution took 490 ms, finished with status: 'crash'"
there is ongoing issue due to which it does not return exact error. https://issuetracker.google.com/issues/155215191
I need help with
Upvotes: 0
Views: 1263
Reputation: 1960
That's because you are returning an HTTP response object, instead of the JSON response of your request.
You should do something like this:
from flask import jsonify
def check_refresh_date(request):
import requests
res = requests.get(
"https://coronavirus.data.gov.uk/downloads/json/coronavirus-cases_latest.json")
data = res.json()
return jsonify(data)
Upvotes: 1