import uuid


def create_files(df):
    """Creates several files to be downloaded from the given DataFrame.

    Given the specified DataFrame containing either the queried data items
    or a summary of them, it transforms such DatFrame into several file types
    to be further downloaded.

    Parameters
    ----------
    df : DataFrame
        DataFrame containing either the queried data items or a summary of them

    Returns
    -------
    str
        URI of the CSV file
    str
        URI of the HTML file
    str
        URI of the JSON file
    str
        URI of the XLS file
    """

    # Create CSV
    filename = f"{uuid.uuid1()}.csv"
    uriCSV = f"tmp/{filename}"

    df.to_csv(uriCSV)

    # Create HTML
    filename = f"{uuid.uuid1()}.html"
    uriHTML = f"tmp/{filename}"

    df.to_html(uriHTML)

    # Create JSON
    filename = f"{uuid.uuid1()}.json"
    uriJSON = f"tmp/{filename}"

    try:
        json = df.to_json(force_ascii=False)
        with open(uriJSON, "w", encoding='utf8') as file:
            file.write(json)

    except:
        uriJSON = None

    # Convert to XML
    filename = f"{uuid.uuid1()}.xls"
    uriXLS = f"tmp/{filename}"

    df.to_excel(uriXLS)

    return uriCSV, uriHTML, uriJSON, uriXLS