How to debug Dash (Flask) in Docker + VSCode + remote connection environment

I was addicted to it at work, so I made a personal note.

0. Remotely connect to Docker container on VS Code

(Since there are already abundant commentary articles, it is omitted)

1. Specify the app made with flask.Flask in the server option of dash.Dash

app.py


import flask
import dash
_app = flask.Flask(__name__)
app = dash.Dash(__name__, server=_app)

2. VS Code Debug feature → Add configuration → Select "Python: Flask"

The following configuration is added to launch.json.

launch.json


{
    "name": "Python: Flask",
    "type": "python",
    "request": "launch",
    "module": "flask",
    "env": {
        "FLASK_APP": "app.py",
        "FLASK_ENV": "development",
        "FLASK_DEBUG": "0"
    },
    "args": [
        "run",
        "--no-debugger",
        "--no-reload",
        #If necessary--host and--Add port
    ],
    "jinja": true
}

3. Select the added configuration and debug

You can debug the behavior of Dash on the browser (variable creation & update, callback, etc.) in real time.

Recommended Posts

How to debug Dash (Flask) in Docker + VSCode + remote connection environment
How to log in to Docker + NGINX
How to access environment variables in Python
How to create an NVIDIA Docker environment
How to use tensorflow under docker environment
Introduction to docker Create ubuntu environment in ubuntu
How to reflect ImageField in Django + Docker (pillow)
Super easy! Python + Flask environment in Docker quickly
[TF] How to build Tensorflow in Proxy environment
How to debug selenium
How to build a Django (python) environment on docker
How to change static directory from default in Flask
How to resolve SSL module errors in Anaconda environment
How to use jupyter lab in Windows 10 local environment
How to pass matplotlib backend settings in environment variables
How to use Docker to containerize your application and how to use Docker Compose to run your application in a development environment
Ssh to virtual environment with remote development of vscode
How to install poetry (error handling) in zsh environment
[CentOS 7.7] From desktop environment installation to remote desktop connection possible (from minimum installation)
How to debug the Python standard library in Visual Studio
How to use VS Code in venv environment on windows
A note on how to load a virtual environment in PyCharm
From environment construction to deployment for flask + Heroku with Docker
How to develop in a virtual environment of Python [Memo]
How to implement Python EXE for Windows in Docker container
[Shell] How to get the remote default branch in Git
Collaborate in a remote environment
HTTP environment variables in Flask
How to develop in Python
Repeated @ app.callback in Dash How to write Input and State neatly
How to use jupyter notebook without polluting your environment with Docker
Learn how to use Docker through building a Django + MySQL environment
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
Run eclipse in Docker environment (noVNC)
How to write soberly in pandas
Flask reuse How to write html
How to use SQLite in Python
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to delete a Docker container
How to write Docker base image
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to call PyTorch in Julia
Comfortable Jupyter Lab (Python) analysis environment created with Docker + VSCode + Remote Container
I wanted to use jupyter notebook with docker in pip environment (opticspy)
How to install python package in local environment as a general user
How to make a container name a subdomain and make it accessible in Docker
Environment maintenance made with Docker (I want to post-process GrADS in Python
I compared using Dash and Streamlit in Docker environment using B league data
How to read environment variables from .env file in PyCharm (on Mac)