Avaiga / taipy-gui

Graphical User Interface generator for Taipy
Apache License 2.0
60 stars 18 forks source link

Can't find Flask server #789

Closed florian-vuillemot closed 1 year ago

florian-vuillemot commented 1 year ago

I need to retrieve the Flask object to expose my application with Gunicorn. I tried with the get_flask_app method, but I got the following error:

[2023-06-12 17:21:18 +0200] [451] [INFO] Starting gunicorn 20.1.0
[2023-06-12 17:21:18 +0200] [451] [INFO] Listening at: http://0.0.0.0:8000 (451)
[2023-06-12 17:21:18 +0200] [451] [INFO] Using worker: sync
[2023-06-12 17:21:18 +0200] [452] [INFO] Booting worker with pid: 452
[2023-06-12 17:21:19 +0200] [452] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/taipy/venv/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/taipy/app.py", line 3, in <module>
    app = tp.Gui(page="# Getting started with *Taipy*").get_flask_app()
  File "/home/taipy/venv/lib/python3.9/site-packages/taipy/gui/gui.py", line 1672, in get_flask_app
    return self._server.get_flask()

The application code:

import taipy as tp

app = tp.Gui(page="# Getting started with *Taipy*").get_flask_app()

My Taipy dependencies:

taipy==2.2.0
taipy-config==2.2.0
taipy-core==2.2.3
taipy-gui==2.2.1
taipy-rest==2.2.1
FredLL-Avaiga commented 1 year ago

app = gui.run(run_server=False) returns the Flask instance