The code below is the PA generated script when I created an API token (minus the actual token):
import requests
my_domain = 'roasted.pythonanywhere.com'
username = 'roasted'
token = 'token'
response = requests.post(
'https://www.pythonanywhere.com/api/v0/user/{username}/webapps/{domain}/reload/'.format(
username=username, domain=my_domain),
headers={'Authorization': 'Token {token}'.format(token=token)})
if response.status_code == 200:
print('All OK')
else:
print('Got unexpected status code {}: {!r}'.format(response.status_code, response.content))
I tested a few of the other API calls and they work fine.
I need to reload my webapp at the end of a scheduled task or the newly created json file won't be loaded on my site.
Here's the error message:
Got unexpected status code 500: b'<html>\r\n<head><title>500 Internal Server Error</title></head>\r\n<body bgcolor="white">\r\n<center><h1>500 Internal Server Error</h1></center>\r\n<hr><center>openresty/1.9.15.1</center>\r\n</body>\r\n</html>\r\n'