HI team
I am facing issue with Genie while running below code for julie.
module App
using Genie.Router
using Genie
export vertical_addition
function vertical_addition(numbers::Vector{Union{Int, Float64}})
# Convert numbers to strings for vertical display
num_strs = map(string, numbers)
# Calculate the sum of the numbers
sum_result = sum(numbers)
sum_str = string(sum_result)
# Find the maximum length for padding
max_len = maximum([length(num_str) for num_str in num_strs]..., length(sum_str))
# Pad each number string for vertical alignment
padded_numbers = map(num_str -> lpad(num_str, max_len), num_strs)
sum_str = lpad(sum_str, max_len)
# Prepare the vertical format with steps
steps = join(padded_numbers, "\n+\n")
steps *= "\n" * repeat("-", max_len) * "\n" * sum_str
return steps
end
end
using .App
using Genie
using Genie.Router
using Genie.Requests
route("/vertical_addition") do
# Get all query parameters (assumed to be numbers)
params_dict = params()
# Parse the numbers as either integers or floating-point values
parsed_numbers = [tryparse(Float64, string(value)) for value in values(params_dict) if tryparse(Float64, string(value)) !== nothing]
# Handle case where no valid numbers are provided
if isempty(parsed_numbers)
return text("No valid numbers were provided.")
end
# Call the vertical_addition function
result = App.vertical_addition(parsed_numbers)
# Return the result as a plain text response
text(result)
end