flet-dev / flet-dev/flet

get_upload_url does not work with Pyodide static website

Open
#2,984 1 comment 0 reactions 1 assignee View on GitHub

@FeodorFitsner is already working on this.

Since Nov 22, 2025.

Dominant language
Python
Stars
17k
Forks
694
Avg merge
1d 14h
Merged PRs (30d)
33

Description

I'm making a web app with the ability to upload data. There was a problem using the get_upload_url method. When running from source code everything works correctly. But after building the web application (I use the command flet build web --no-web-splash) and deploying it on localhost, the file upload option does not work. The following error appears in the browser console (Google Chrome): <PyodideTask finished name='Task-26' coro=<app_async..on_event() done, defined at C:\Users\Aleksei\AppData\Local\Temp\ serious_python_temp12899567_pypackages_\flet\flet.py:52> exception=Exception('getUploadUrl command is not supported.')>

Part of code (with upload files) to reproduce the issue:

def get_df_list(data_names: str) -> list[pd.DataFrame]:
    data_names_list = data_names.split('\n')
    for idx_name in range(len(data_names_list)):
        data_names_list[idx_name] = os.path.join('uploads', data_names_list[idx_name])
    df_list = []
    for path_name in data_names_list:
        df = pd.read_csv(path_name)
        df_list.append(df)
    del df
 # --- loading files ---

    def pick_files_result(e):
        selected_files.value = None
        selected_files.update()
        upload_list = []
        if pick_files_dialog.result is not None and pick_files_dialog.result.files is not None:
            for f in pick_files_dialog.result.files:
                upload_list.append(
                    ft.FilePickerUploadFile(
                        f.name,
                        upload_url=page.get_upload_url(f.name, 600),
                    )
                )
            pr.visible = True
            pr.update()
            time.sleep(3)  # TODO del this
            pick_files_dialog.upload(upload_list)

        print(upload_list)
        if len(upload_list) > 0:
            for i in range(len(upload_list)):
                if i == 0:
                    selected_files.value = upload_list[i].name
                else:
                    selected_files.value += f'\n{upload_list[i].name}'
        else:
            selected_files.value = "Файл не выбран!"

        if selected_files.value != "Файл не выбран!":
            get_df_list(selected_files.value)
        pr.visible = False
        pr.update()
        selected_files.update()
        files_names_list.value = str(os.listdir('uploads'))
        test_path_dir_uploads.update()
        print(selected_files)

    pick_files_dialog = ft.FilePicker(on_result=pick_files_result)
    selected_files = ft.Text(color=ft.colors.BLACK, text_align=ft.MainAxisAlignment.CENTER)

    page.overlay.append(pick_files_dialog)

    pr = ft.Row(
        [
            ft.ProgressRing(width=16, height=16, stroke_width=2, color=ft.colors.BLACK),
            ft.Text(color=ft.colors.BLACK, text_align=ft.MainAxisAlignment.CENTER, value="Загрузка файлов...")
        ],
        visible=False,
        alignment=ft.MainAxisAlignment.CENTER,
    )

    test_path = ft.Row(
        [
            ft.Text(color=ft.colors.BLACK, text_align=ft.MainAxisAlignment.CENTER, value=os.getcwd())
        ],
        visible=True,
        alignment=ft.MainAxisAlignment.CENTER,
    )

    test_path_dir = ft.Row(
        [
            ft.Text(color=ft.colors.BLACK, text_align=ft.MainAxisAlignment.CENTER, value=str(os.listdir()))
        ],
        visible=True,
        alignment=ft.MainAxisAlignment.CENTER,
    )

    files_names_list = ft.Text(color=ft.colors.BLACK, text_align=ft.MainAxisAlignment.CENTER, value=str(os.listdir('uploads')))

    test_path_dir_uploads = ft.Row(
        [
            files_names_list,
        ],
        visible=True,
        alignment=ft.MainAxisAlignment.CENTER,
    )

    upload_obj = ft.Column(
        [
          ft.Container(
              content=ft.Column(
                  [
                      ft.ElevatedButton(
                          'Выберите файл',
                          icon=ft.icons.UPLOAD_FILE,
                          on_click=lambda _: pick_files_dialog.pick_files(
                              allow_multiple=True,
                              allowed_extensions=['csv'],
                          ),
                      ),
                      selected_files,
                      pr,
                      test_path,  # TODO del this
                      test_path_dir,  # TODO del this
                      test_path_dir_uploads,  # TODO del this
                  ],
                  horizontal_alignment=ft.CrossAxisAlignment.CENTER,
              ),
              height=page.window_height - my_app_bar_h,
              alignment=ft.alignment.center,
              padding=ft.padding.only(top=my_app_bar_h),
          ),
        ],
        visible=False,
    )

Describe the results you received:

Flet version (pip show flet):

Name: flet
Version: 0.21.2
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: c:\users\aleksei\desktop\drillingmixturewebapp\venv\lib\site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by:

Give your requirements.txt file (don't pip freeze, instead give direct packages):

flet==0.21.2
pandas==1.5.3
numpy==1.26.1

Operating system: Windows 10:

Additional environment details: Python 3.10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.