Spaces:
Sleeping
Sleeping
File size: 2,949 Bytes
ce47143 e1bf3e5 d882362 e1bf3e5 f34e62f e1bf3e5 f34e62f e1bf3e5 83d201c c4a8ce1 8d18a89 e1bf3e5 c4a8ce1 8d18a89 e1bf3e5 c00b7af 5e762bd e1bf3e5 c00b7af d882362 c00b7af fe8ec2d d882362 10f92df d882362 c00b7af ce47143 83d201c c00b7af 1500a44 ce47143 1500a44 dac4384 e1bf3e5 c00b7af 5ebc6da c00b7af 863671d c00b7af fe8ec2d f34e62f fe8ec2d f34e62f fe8ec2d dac4384 |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import gradio as gr
import random
glHTML = """
<html>
<head>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
</head>
<body>
<gradio-lite>
{0}
</gradio-lite>
</body>
</html>
"""
defaultCode = """
import gradio as gr
def greet(name):
return "Hello, " + name + "!"
gr.Interface(greet, "textbox", "textbox").launch()
"""
def letterize(x):
names = [
"Jake",
"John",
"Greg Heffley",
"Mark Zuckerberg",
"Ian",
"Scotland",
"Bill Gates",
"Lil Nas X",
"Micheal Kovach"
]
return f"""
Dear {random.choices(names)[0]},
{x}
Sincerely, {random.choices(names)[0]}
"""
def flip_text(x):
return x[::-1]
def txtRouletteHandler(x, y):
rn = random.randrange(2)
print(rn)
if (rn == 1):
return letterize(x)
elif (rn == 2):
return flip_text(x)
else:
return flip_text(x)
def check_cc(n):
digits = [int(d) for d in str(n)]
for i in range(1, len(digits), 2):
digits[i] *= 2
total = sum(digits)
return "Valid\n\nNOW DON'T GO POSTING THAT NUMBER." if total % 2 == 0 and len(digits) == 16 else "Invalid"
#left for if i find out how to use this
def genGrUI(code):
print(glHTML.format(code))
return glHTML.format(code)
with gr.Blocks(title="Josiah's Gradio Playground") as playground:
gr.Markdown("# Josiah's Gradio Playground")
gr.Markdown("Playing around with Gradio. Note that tabs marked as ⚠️ should not be used for malicious purposes.")
with gr.Tab("Tabs within Tabs"):
with gr.Tab("1. first"):
gr.Markdown("you're on 1")
with gr.Tab("2. third"):
gr.Markdown("you're on second")
with gr.Tab("Text Roulette"):
gr.ChatInterface(fn=txtRouletteHandler, examples=["Hello from USA!", "How is your day?", "skcus teliot idibiks"])
with gr.Tab("⚠️ CC Validator"):
gr.Markdown("# THIS WAS NOT MEANT FOR MALICIOUS PURPOSES!")
gr.Markdown("This is meant to be a fun tool to use.")
num = gr.Textbox(label="CC Number (DO NOT USE MALICIOUSLY)")
valid = gr.Textbox(label="Is valid (DO NOT USE MALICIOUSLY)")
with gr.Row():
validate = gr.Button("Validate", variant="primary")
gr.ClearButton([num, valid])
validate.click(fn=check_cc, inputs=num,outputs=valid)
with gr.Tab("Changelog"):
with gr.Accordion("11/26/2023"):
with gr.Accordion("latest"):
gr.Markdown("fixed names appearing as lists")
with gr.Accordion("other"):
gr.Markdown("Removed gradio in gradio")
gr.Markdown("Added gradio in gradio")
gr.Markdown("Added CC Validator")
playground.launch() |