ghaffarmumtat123 commited on
Commit
cf1cc65
·
verified ·
1 Parent(s): 8169267

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -64
app.py CHANGED
@@ -1,66 +1,60 @@
1
- #[secrets]
2
- SANITY_API_TOKEN = "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"
3
- import requests
4
- import pandas as pd
5
  import streamlit as st
 
 
 
 
6
 
7
- # Sanity project details
8
- project_id = "your-sanity-project-id" # Replace with your Sanity project ID
9
- dataset = "your-sanity-dataset-name" # Replace with your dataset name
10
-
11
- # Try to fetch the SANITY_API_TOKEN from secrets
12
- try:
13
- token = st.secrets["SANITY_API_TOKEN"] # Fetch API token from Streamlit secrets
14
- except KeyError:
15
- st.error("SANITY_API_TOKEN not found in secrets! Please check the secrets.toml file.")
16
- token = None
17
-
18
- # Proceed only if the token is valid
19
- if token:
20
- # Sanity API URL for querying tasks
21
- url = f'https://{project_id}.api.sanity.io/v1/data/query/{dataset}'
22
-
23
- # GROQ query to get tasks
24
- groq_query = """
25
- *[_type == "task"]{
26
- _id,
27
- title,
28
- description,
29
- status,
30
- dueDate
31
- }
32
- """
33
-
34
- # Prepare headers with authorization token
35
- headers = {
36
- 'Authorization': f'Bearer {token}' # Add the API token for authentication
37
- }
38
-
39
- # Streamlit title and description
40
- st.title('Sanity Task List')
41
- st.write("This app displays tasks fetched from a Sanity CMS project.")
42
-
43
- # Initialize tasks_df to an empty DataFrame in case of error
44
- tasks_df = pd.DataFrame()
45
-
46
- # Make the GET request to Sanity API
47
- response = requests.get(url, headers=headers, params={'query': groq_query})
48
-
49
- # Check if the request was successful
50
- if response.status_code == 200:
51
- # Parse the JSON response into a DataFrame if successful
52
- tasks = response.json()['result']
53
- tasks_df = pd.DataFrame(tasks)
54
-
55
- # Convert 'dueDate' field to datetime if it exists in the response
56
- if 'dueDate' in tasks_df.columns:
57
- tasks_df['dueDate'] = pd.to_datetime(tasks_df['dueDate'])
58
-
59
- # Display the tasks in the DataFrame as a table
60
- st.write("### Your Task List:")
61
- st.dataframe(tasks_df)
62
- else:
63
- # Handle errors by displaying a message
64
- st.error(f"Error fetching tasks: {response.status_code} - {response.text}")
65
- else:
66
- st.error("API token not found. Please ensure the secrets.toml file is configured correctly.")
 
 
 
 
 
1
  import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+ from PIL import Image, ImageDraw
4
+ import plotly.graph_objects as go
5
+ import numpy as np
6
 
7
+ # --- Wireframe Design ---
8
+ st.title("My Design Prototype")
9
+
10
+ # Create a simple wireframe design for a UI mockup
11
+ fig, ax = plt.subplots()
12
+
13
+ # Drawing a simple mockup of a webpage (a box representing a webpage layout)
14
+ rect = plt.Rectangle((0.1, 0.1), 0.8, 0.8, linewidth=2, edgecolor='blue', facecolor='lightblue')
15
+ ax.add_patch(rect)
16
+
17
+ # Add title and buttons as placeholders
18
+ plt.text(0.5, 0.9, "My Webpage", horizontalalignment='center', fontsize=12, weight='bold')
19
+
20
+ # Adding a button
21
+ plt.text(0.5, 0.5, "Submit", horizontalalignment='center', fontsize=10, weight='bold', color='white', bbox=dict(facecolor='blue', alpha=0.5))
22
+
23
+ # Adjust axis and show the design
24
+ plt.xlim(0, 1)
25
+ plt.ylim(0, 1)
26
+ plt.axis('off') # Hide axes
27
+ st.pyplot(fig)
28
+
29
+ # --- Image Generation ---
30
+ img = Image.new('RGB', (300, 150), color = (255, 255, 255))
31
+ d = ImageDraw.Draw(img)
32
+
33
+ # Add text or simple design elements
34
+ d.text((10,10), "Design Prototype", fill=(0, 0, 0))
35
+
36
+ # Show image
37
+ st.image(img, caption="Prototype Image")
38
+
39
+ # --- Plotly Chart ---
40
+ fig_plotly = go.Figure(data=go.Scatter(x=[1, 2, 3], y=[4, 5, 6], mode='lines'))
41
+
42
+ fig_plotly.update_layout(title='Data Prototype',
43
+ xaxis_title='X Axis',
44
+ yaxis_title='Y Axis')
45
+
46
+ # Display Plotly chart
47
+ st.plotly_chart(fig_plotly)
48
+
49
+ # --- Figma API (If needed) ---
50
+ # This is a placeholder for your Figma integration
51
+ st.write("Figma integration can be added here.")
52
+
53
+ # --- Gradio UI (If needed) ---
54
+ import gradio as gr
55
+
56
+ def greet(name):
57
+ return f"Hello {name}!"
58
+
59
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
60
+ iface.launch(inline=True)