Spaces:
Runtime error
Runtime error
Commit ·
b508f76
1
Parent(s): 245110e
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
|
|
|
| 4 |
def get_code_screenshot(code, title, theme, background, darkMode, padding, language):
|
| 5 |
payload = {
|
| 6 |
"code": code,
|
|
@@ -19,19 +20,24 @@ def get_code_screenshot(code, title, theme, background, darkMode, padding, langu
|
|
| 19 |
else:
|
| 20 |
return f"Failed to get image: {response.status_code}"
|
| 21 |
|
|
|
|
| 22 |
iface = gr.Interface(
|
| 23 |
fn=get_code_screenshot,
|
| 24 |
inputs=[
|
| 25 |
-
gr.inputs.Textbox(lines=10, placeholder="Enter your code here..."),
|
| 26 |
-
gr.inputs.Textbox(default="Untitled-1", placeholder="Enter title..."),
|
| 27 |
gr.inputs.Dropdown(choices=["breeze", "candy", "crimson", "falcon", "meadow", "midnight", "raindrop", "sunset"], label="Theme"),
|
| 28 |
gr.inputs.Checkbox(default=True, label="Background"),
|
| 29 |
gr.inputs.Checkbox(default=True, label="Dark Mode"),
|
| 30 |
gr.inputs.Dropdown(choices=["16", "32", "64", "128"], label="Padding"),
|
| 31 |
-
gr.inputs.Textbox(default="auto", placeholder="Enter language..."),
|
| 32 |
],
|
| 33 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
| 34 |
)
|
| 35 |
|
|
|
|
| 36 |
if __name__ == "__main__":
|
| 37 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
# Function to interact with the Rayso API
|
| 5 |
def get_code_screenshot(code, title, theme, background, darkMode, padding, language):
|
| 6 |
payload = {
|
| 7 |
"code": code,
|
|
|
|
| 20 |
else:
|
| 21 |
return f"Failed to get image: {response.status_code}"
|
| 22 |
|
| 23 |
+
# Gradio Interface
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=get_code_screenshot,
|
| 26 |
inputs=[
|
| 27 |
+
gr.inputs.Textbox(lines=10, placeholder="Enter your code here...", label="Code"),
|
| 28 |
+
gr.inputs.Textbox(default="Untitled-1", placeholder="Enter title...", label="Title"),
|
| 29 |
gr.inputs.Dropdown(choices=["breeze", "candy", "crimson", "falcon", "meadow", "midnight", "raindrop", "sunset"], label="Theme"),
|
| 30 |
gr.inputs.Checkbox(default=True, label="Background"),
|
| 31 |
gr.inputs.Checkbox(default=True, label="Dark Mode"),
|
| 32 |
gr.inputs.Dropdown(choices=["16", "32", "64", "128"], label="Padding"),
|
| 33 |
+
gr.inputs.Textbox(default="auto", placeholder="Enter language...", label="Language"),
|
| 34 |
],
|
| 35 |
+
outputs=[
|
| 36 |
+
gr.outputs.Image(type="url", label="Generated Image"),
|
| 37 |
+
],
|
| 38 |
+
live=False # Set to False to only call the function when the submit button is pressed
|
| 39 |
)
|
| 40 |
|
| 41 |
+
# Launch the Gradio interface
|
| 42 |
if __name__ == "__main__":
|
| 43 |
iface.launch()
|