dimanche 7 avril 2019

How to make pandas read a database from a given link by the user in a website?

I wanna use pandas to make a page in my website which allows to user to input any given database API, for example: https://data.gov.il/api/action/datastore_search?resource_id=c8b9f9c8-4612-4068-934f-d4acd2e3c06e&limit=1000

and read it, and display a table of it on the website plus a graph. How do I do this? thanks in advance.

Tried putting in the code, instead of the link itself, tried making it a parameter. Didn't work.

r = requests.get( the link ) x = r.json()

df = pd.DataFrame.from_dict(x["result"]["records"]) db_table= df.head(5).to_html(escape=False)

fig, ax = plt.subplots() df['_id'].hist()

encoded = fig_to_base64(fig) plot_img = ''. format(encoded.decode('utf-8'))

this is not all of the code, as there are more functions in the same file.

Didn't go as expected, got internal server error instead.




Aucun commentaire:

Enregistrer un commentaire