Spaces:
Sleeping
Sleeping
File size: 1,861 Bytes
acc66a1 |
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 |
module myapp
using Genie.Renderer.Html
############## FUNCTIONS ##############
function color_text(text_chunks::Vector{String}, color_values::Vector{String})
# Ensure text_chunks and color_values have the same length
if length(text_chunks) != length(color_values)
throw(ArgumentError("Text and color arrays must have the same length"))
end
# Create HTML with colored spans
html = "<p>"
for (text, color) in zip(text_chunks, color_values)
html *= """<span style="color: $color;">$text</span> """
end
html *= "</p>"
return html_safe(html) # Use html_safe to mark the HTML as safe to render
end
text_chunks = ["Hello", "world", "this", "is", "Genie.jl!"]
color_values = ["#ff0000", "#00ff00", "#0000ff", "#ff00ff", "#00ffff"]
function mycontroller()
html = color_text(text_chunks, color_values)
return html
end
using Colors
function generate_gradient(start_color::Color, end_color::Color, num_steps::Int)
gradient = []
for i in 0:num_steps-1
ratio = i / (num_steps - 1)
color = blend(start_color, end_color, ratio)
push!(gradient, string(color))
end
return gradient
end
start_color = RGB(1, 0, 0) # Red
end_color = RGB(0, 0, 1) # Blue
color_values = generate_gradient(start_color, end_color, length(text_chunks))
mycolortext = color_text(text_chunks, color_values)
#h1(mycolortext)
function ui()
[
h2("Youtube video transcriber")
input("url", :url, style="width:500px")
# button("Transcribe", @click("process = !process"))
button("Transcribe", @click("transcribing = true"), loading=:transcribing)
button("Download", @click("download = !download; downloading=true"), loading=:downloading)
h4("Transcription:")
p("{{transcription}}")
]
end
@page("/", "app.jl.html")
Server.up()
end |