Spaces:
Runtime error
Runtime error
Commit
•
ed2da69
1
Parent(s):
a4c5b1d
ADD app.py with dummy json and dataframe
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import requests
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
st.header('Deploy Streamlit project to HuggingFace spaces!')
|
8 |
+
st.write("Let's make a request to [dummy API](https://jsonplaceholder.typicode.com/users) and display the results")
|
9 |
+
url = "https://dummyjson.com/quotes"
|
10 |
+
|
11 |
+
|
12 |
+
@st.cache_data
|
13 |
+
def get_json_response(url:str) :
|
14 |
+
response = requests.get(url)
|
15 |
+
return response.json()
|
16 |
+
|
17 |
+
st.subheader('Json')
|
18 |
+
st.json(get_json_response(url), expanded=False)
|
19 |
+
"----"
|
20 |
+
|
21 |
+
st.subheader('DataFrame')
|
22 |
+
st.dataframe(pd.DataFrame.from_dict(dict(get_json_response(url))['quotes']))
|