Skip to content

Commit 04213c2

Browse files
committed
Expose Flask server for Azure App Service deployment with gunicorn
1 parent 3bcdfa7 commit 04213c2

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""try and accept for imports to get rid of deprecation warning"""
1717

1818
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
19+
server = app.server # Expose the Flask server for Azure App Service (gunicorn entry point)
1920

2021

2122
# Fetch prices from local CSV using pandas
@@ -436,4 +437,6 @@ def update_scatter_plot(all_tickers, price):
436437

437438

438439
if __name__ == "__main__":
439-
app.run_server(debug=True)
440+
debug = os.environ.get("DASH_DEBUG", "false").lower() == "true"
441+
port = int(os.environ.get("PORT", 8050))
442+
app.run_server(debug=debug, host="0.0.0.0", port=port)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ dash==2.16.0
22
dash_bootstrap_components==1.5.0
33
pandas==2.2.1
44
plotly==5.24.1
5+
gunicorn==22.0.0

startup.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gunicorn --bind=0.0.0.0 --timeout 600 app:server

0 commit comments

Comments
 (0)