Search code examples
taipy

getting RuntimeError when running with taipy


I try to work with taipy but i am getting this error:

RuntimeError: The Werkzeug web server is not designed to run in production. Pass allow_unsafe_werkzeug=True to the run() method to disable this error.

I am working with docker-compose, this is my docker-compose.yml: version: "3.9" services:

   my_test:
        build: .
        container_name: my_test
        volumes:
            - .:/app
        ports:
            - "5000:5000"

This in my Dockerfile: FROM python:3.9

WORKDIR /app COPY . /app RUN pip install -r requirements.txt

CMD [ "python", "./app.py" ]

This is my requirements.txt:

docker
gpt-engineer
flask==2.2
marshmallow-sqlalchemy==0.26.1
taipy

and this is my app.py:

from flask import Flask
from taipy import Gui

flask_app = Flask(__name__)

@flask_app.route("/home")
def home_page():
    return "The home page."

gui = Gui(page="# Taipy application", flask=flask_app)
gui.run(allow_unsafe_werkzeug=True)

and i am getting this output:

ilai@ilai-dell-g15-5520:~/Code/taipy$ docker compose up
[+] Running 2/2
 ⠿ Network taipy_default  Created                                                                                                                  0.1s
 ⠿ Container my_test      Created                                                                                                                  0.1s
Attaching to my_test
my_test  |  * Server starting on http://127.0.0.1:5000
my_test  | Traceback (most recent call last):
my_test  |   File "/app/./app.py", line 11, in <module>
my_test  |     gui.run(allow_unsafe_werkzeug=True)
my_test  |   File "/usr/local/lib/python3.9/site-packages/taipy/gui/gui.py", line 1151, in run
my_test  |     return self._server.runWithWS(
my_test  |   File "/usr/local/lib/python3.9/site-packages/taipy/gui/server.py", line 253, in runWithWS
my_test  |     self._ws.run(self._flask, host=host, port=port, debug=debug, use_reloader=use_reloader)
my_test  |   File "/usr/local/lib/python3.9/site-packages/flask_socketio/__init__.py", line 641, in run
my_test  |     raise RuntimeError('The Werkzeug web server is not '
my_test  | RuntimeError: The Werkzeug web server is not designed to run in production. Pass allow_unsafe_werkzeug=True to the run() method to disable this error.

I tried to work without flask and got the same problem


Solution

  • Is having flask==2.2 a requirement? Taipy already installs Flask as one of its requirements and this other version solves your issue.

    These requirements normally let you deploy your application:

    taipy
    docker
    gpt-engineer
    marshmallow-sqlalchemy==0.26.1