-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
112 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from dash import Dash, html, dcc | ||
import dash_bootstrap_components as dbc | ||
import plotly.express as px | ||
from dash.dependencies import Input, Output | ||
import pandas as pd | ||
|
||
# assume you have a "long-form" data frame | ||
# see https://plotly.com/python/px-arguments/ for more options | ||
df = pd.DataFrame({ | ||
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"], | ||
"Amount": [4, 1, 2, 2, 4, 5], | ||
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"] | ||
}) | ||
|
||
fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group") | ||
|
||
|
||
def serve_layout(): | ||
return html.Div(children=[ | ||
html.H1(children='Hello Dash'), | ||
|
||
html.Div(children=''' | ||
Dash: A web application framework for your data. | ||
'''), | ||
html.Div([dcc.Graph(id='example-graph',figure=fig)]), | ||
html.Div( | ||
children=[ | ||
html.P(children=[ | ||
"Last Updated: ", | ||
html.Span(id='time',children=["hello"]), | ||
]), | ||
html.P("Please email the digitalization team with any errors that you find including a screenshot"), | ||
dcc.Dropdown( | ||
id='main-viewer', | ||
options=[ | ||
{'label': 'Area-Adjusted', 'value': 'Area'}, | ||
{'label': 'APO', 'value': 'APO'} | ||
], | ||
value='Area' | ||
), | ||
] | ||
), | ||
]) | ||
|
||
|
||
external_stylesheets = [dbc.themes.BOOTSTRAP] | ||
app = Dash(__name__, external_stylesheets=external_stylesheets, | ||
suppress_callback_exceptions=True) | ||
app.layout = serve_layout() | ||
|
||
|
||
@app.callback([Output('time', 'children')], | ||
Input('main-viewer', 'value')) | ||
def update_time(view): | ||
if view == 'APO': | ||
return ["helloworld"] | ||
else: | ||
return ["heihei"] | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run_server(debug=True) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Dockerfile | ||
|
||
# pull the official docker image | ||
FROM python:3.9.4-slim | ||
|
||
# set work directory | ||
WORKDIR /app | ||
|
||
# set env variables | ||
# PYTHONDONTWRITEBYTECODE: Prevents Python from writing pyc files to disc (equivalent to python -B option) | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
|
||
# PYTHONUNBUFFERED: Prevents Python from buffering stdout and stderr (equivalent to python -u option) | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# install dependencies | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
# copy project | ||
COPY . . |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import asyncio | ||
import uvicorn | ||
from fastapi import FastAPI | ||
|
||
app = FastAPI(title="FastAPI, Docker") | ||
|
||
|
||
@app.get("/") | ||
async def root(): | ||
return {"message": "Hello World"} | ||
|
||
|
||
async def main(): | ||
config = uvicorn.Config("app.main:app", port=5000, log_level="info") | ||
server = uvicorn.Server(config) | ||
await server.serve() | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3.8" | ||
|
||
services: | ||
web: | ||
build: . | ||
command: python -m app.main | ||
ports: | ||
- 8080:5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fastapi | ||
uvicorn |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.