write me a web page that interacts with a REST API backend that uses Postgres DB
It gave me the guidance to create app.py, index.html, and style.css
- It missed (which caused a Jinja error) to create a Templates directory and put the index.html file in it.
- After that, it needed connection info for the DB (which it does mention)
- It expects the REST API and DB to be created separately.
- After that, it needed to know the database table name (it threw a pefect error on this)
now show me how to create a web form that allows me to edit the data using the REST API
-
After that, had to ask again how to add updates (PUT) and follow that
-
Had to google how to fix Jinja2 error on stylesheet not loading
-
Had to figure out how to add
+ id
to my URL for PUT for one of the suggested functions
The most challenging hurdle so far has been getting delete
to work. The code ChatGPT provided
kept erroring and the buttons were titled delete undefined
. I kept explaining to ChatGPT that
I was getting errors and it suggested some debug code which lead me to indicating what my data looked
like and then it suggested a different way to make the calls work. Specifically:
deleteButton.textContent = `Delete ${data.id}`;
didn't work. but
const userId = data[0]; // Access the ID from the first element of the inner array
const deleteButton = document.createElement('button');
deleteButton.textContent = `Delete ${userId}`;