Forums

Can I populate a web page using API data and PythonAnywhere?

I am using JavaScript to access an API to get some data for a web page. I wrote a Python3 program to access the API to get the same data. Right now, I am just writing the retrieved data to a text file in Python3.

Is there a way I can use Python 3 and PythonAnywhere to get the data from the API and populate a web page?

I was going to start reading the "A beginner's guide to building a simple database-backed Flask website on PythonAnywhere". But, before I did that, I thought I would post the question here to see if I could (or should) bypass using a database.

-

Additional details about this project:

The API I am using is from the eBird website that involves sightings of rare birds for a location. There is one particular API end point that I am using that has an optional parameter which allows me to get additional data fields. But, it also sometimes retrieves multiple records for a single sighting. (This is not an error. If a sighting of a rare bird has multiple photos uploaded, each photo causes a record of data to be created. On top of that, the records aren't sorted when they are retrieved if they are on the same date. So, the multiple records may be mixed up with other records for the same date.) I cannot weed out the multiple/unsorted records with JavaScript using the optional parameter. The code runs too slowly with the amount of data coming in and the browser locks up. So, I tried using Python3 using the optional parameter. The Python3 code easily handles the multiple unsorted rows and writes to the text file quickly. But, I would really like to include this additional data on a web page if possible.

The database is the correct place to store data in. It's much better compared to the text file.