I have a Dash app embedded into a Flask App that I have been serving locally via gunicorn
. Lately, I am running into issue serving the app locally.
My directory structure is as follows:
Directory
- index.py
- app.py
auth
-- init.py
Contents of app.py
import dash
import flask
from dash import dcc, html
import dash_bootstrap_components as dbc
import os
# External stylesheets
external_stylesheets = [
stylesheet_path,
{
'href': 'custom.css',
'rel': 'stylesheet'
}
]
application = dash.Dash(__name__,
requests_pathname_prefix='/dashboard/',
#serve_locally = False,
suppress_callback_exceptions = True,
meta_tags=[
{"name": "viewport", "content": "width=device-width, initial-scale=1"}
],
external_stylesheets=external_stylesheets,
)
server = application.server
# Title the app.
application.title = "Stroom - Platform Demo"
Contents of init.py
from flask import Flask,redirect
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.serving import run_simple
from index import application as dashApp
@server_auth.route('/dashboard')
@login_required
def dashboard():
return redirect('/dashboard')
app = DispatcherMiddleware(server_auth,
{'/dashboard': dashApp.server})
# Change to port 80 to match the instance for AWS EB Environment
if __name__ == '__main__':
run_simple('0.0.0.0', 80, app, use_reloader=True, use_debugger=True)
When I run gunicorn auth:app
, I get the following output:
Starting gunicorn 20.1.0
Listening at: http://127.0.0.1:8000 (1182)
[2022-02-23 09:51:24 +0900] [1182] [INFO] Using worker: sync
[2022-02-23 09:51:24 +0900] [1183] [INFO] Booting worker with pid: 1183
/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/dash_bootstrap_components/_table.py:5: UserWarning:
The dash_html_components package is deprecated. Please replace
`import dash_html_components as html` with `from dash import html`
import dash_html_components as html
I am unable to access localhost:8000
or http://127.0.0.1
. I have been successfully running the app locally, but this issue started happening as I have been traveling and connecting to public WiFis / vpns etc.
I tried several things including firewall on/off, DNS flush, restart apache and kill processes running on the port and restart and even attempt to launch on different ports.
What am I missing?