-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.py
39 lines (27 loc) · 815 Bytes
/
func.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import requests
import os
import io
from dotenv import load_dotenv
import streamlit as st
load_dotenv()
API_URL = os.getenv("API_URL")
@st.cache_data
def default():
response = requests.get(API_URL)
if response.status_code == 200:
# data = response.json()
return response.text
else:
data = "An error occurred:", response.status_code
return data
@st.cache_data
def predict(image):
url = API_URL + "/predict/"
payload = {}
files = {"file": ("image.jpg", io.BytesIO(image), "image/jpeg")}
headers = {}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
return response.text
@st.cache_data
def summarize(text: str) -> str:
return "as we said, this endpoint is not yet implemented :(, we're bery sorry"