Good evening everyone I also have a similar case. I am new to dash and server creation. I had to create a plot with Dash (the code follows) and I would like to have it in my already created Appache server.
import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly
import random
import plotly.graph_objs as go
from collections import deque
import pandas as pd
X = deque(maxlen=20)
X.append(0)
Y = deque(maxlen=20)
Y.append(1)
The warning from Flask is there to prevent you from using the development server in production. Indeed, it is not very efficient or secure because it includes a set of functionality for developing and debugging (such as the debugger and reloader). You can find a list WSGI server you can use at Deploying to Production — Flask Documentation (3.0.x). We will dwell into details on using Waitress which is a very easy to setup solution with good performances:
First, you need to install Waitress on your virtual environment with:
pip install waitress
Then you will need to launch your app. This will depend on where your app is created. This is generally done in a Python file close to the root with a line that looks like:
app = flask.Flask(__name__)
(you need to find where Flask is called)
Let’s say this line is in a file named flask_app.py at the location: /projects/flask_deployement/src/flask_app.py
Move to the project root with cd /projects/flask_deployement, noting that the name of the variable running flask was app, we will send the location of the app to Waitress with the path: src.flask_app:app
If we then run Waitress on our server, on port 5000 (this is an example, you can take any available port), we will run the command:
Your app is now running on port 5000. If you have a page on the root endpoint, you can test that the app runs successfully with: curl <http://127.0.0.1:5000/
If you want help with the whole process of deploying a Flask app in production on a server, I have written a whole tutorial here