[Python] Transition variable from function to HTML

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to pass the elements of the file_values array from a function to an HTML file. To display these elements on a web server page. Code with a function to get the file_values array:

    from utils import json_to_dict_list
    from utils import dict_list_to_json

    def get_file_values(USER_ID):
    json_claster = json_to_dict_list('Data/claster-save.json')
    def find_all_by_key(iterable, key, value):
    for index, dict_ in enumerate(iterable):
    if key in dict_ and dict_[key] == value:
    return (dict_)
    dicti = find_all_by_key(json_claster, 'ID', USER_ID)
    file_values = []
    values = list(dicti.values())
    values.remove(values[0])
    for i in values:
    if '.csv' in i:
    file_values.append(i)
    return file_values


    file_values = get_file_values(0)


    HTML file to which you need to pass the names of elements from the array:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta name="viewport" content="width=device-width1, initial-scale=1">
    <meta charset="UTF-8">
    <title>Libary</title>
    </head>
    <body>

    <h1>
    Libary
    </h1>
    <button class="botton_form"
    onclick="window.location.href = 'files';">
    Back
    </button>
    <form method="post">
    </form>



    </body>
    </html>

    Continue reading...

Compartilhe esta Página