Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import http.client
|
| 3 |
+
|
| 4 |
+
# Function to make an API request to Scrapeless
|
| 5 |
+
def get_user_data():
|
| 6 |
+
try:
|
| 7 |
+
# Create HTTPS connection to Scrapeless API
|
| 8 |
+
conn = http.client.HTTPSConnection("api.scrapeless.com")
|
| 9 |
+
|
| 10 |
+
# Set up headers, such as the authorization token if required
|
| 11 |
+
headers = {
|
| 12 |
+
# Uncomment and replace with your API key if needed:
|
| 13 |
+
'Authorization': 'Bearer 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'
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
# Send a GET request to the Scrapeless API
|
| 17 |
+
conn.request("GET", "/api/v1/me", "", headers)
|
| 18 |
+
|
| 19 |
+
# Get the response from the API
|
| 20 |
+
res = conn.getresponse()
|
| 21 |
+
if res.status == 200:
|
| 22 |
+
data = res.read()
|
| 23 |
+
return data.decode("utf-8")
|
| 24 |
+
else:
|
| 25 |
+
return f"Error: {res.status} - {res.reason}"
|
| 26 |
+
|
| 27 |
+
except Exception as e:
|
| 28 |
+
return f"An error occurred: {str(e)}"
|
| 29 |
+
|
| 30 |
+
# Streamlit UI
|
| 31 |
+
st.title("Scrapeless API Data")
|
| 32 |
+
|
| 33 |
+
# Trigger the API call when a button is pressed
|
| 34 |
+
if st.button("Get User Data"):
|
| 35 |
+
result = get_user_data()
|
| 36 |
+
st.write(result) # Display the result in Streamlit
|
| 37 |
+
|
| 38 |
+
|
| 39 |
import streamlit as st
|
| 40 |
import torch
|
| 41 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|