Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests # For making the API call to the Lambda function
|
| 3 |
+
|
| 4 |
+
def process_email(email, password):
|
| 5 |
+
print(email)
|
| 6 |
+
print(password)
|
| 7 |
+
# This is where you'd put your actual Lambda function endpoint
|
| 8 |
+
lambda_endpoint = 'https://your-lambda-function-url'
|
| 9 |
+
|
| 10 |
+
# Preparing the payload to send; ensure this matches what your Lambda function expects
|
| 11 |
+
payload = {
|
| 12 |
+
"email": email,
|
| 13 |
+
"password": password
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
# Making the POST request to the Lambda function
|
| 17 |
+
try:
|
| 18 |
+
response = requests.post(lambda_endpoint, json=payload)
|
| 19 |
+
# Assuming the response is in JSON format and contains a field 'message'
|
| 20 |
+
response_data = response.json()
|
| 21 |
+
if response.status_code == 200:
|
| 22 |
+
# Assuming the Lambda function sends back a response in a JSON format you expect
|
| 23 |
+
return response_data.get('message', 'Success, but no message returned.')
|
| 24 |
+
else:
|
| 25 |
+
return f"Error: {response_data.get('message', 'No message returned.')}"
|
| 26 |
+
except Exception as e:
|
| 27 |
+
return f"Failed to call Lambda function: {str(e)}"
|
| 28 |
+
|
| 29 |
+
iface = gr.Interface(
|
| 30 |
+
process_email, # Replace with your function that processes email and password
|
| 31 |
+
inputs=[
|
| 32 |
+
gr.Textbox(label="Enter Email"),
|
| 33 |
+
gr.Textbox(label="Enter Password", type="password")
|
| 34 |
+
],
|
| 35 |
+
outputs="textbox", # Adjust if your function returns something different
|
| 36 |
+
live=False,
|
| 37 |
+
title="Email Processing Demo",
|
| 38 |
+
description="Enter an email address and password for processing.",
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# Add an Export button to the Textbox output
|
| 42 |
+
iface.launch(share=True)
|