Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bhzheng1 committed Apr 6, 2024
1 parent b95dc0e commit afc65ce
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 47 deletions.
Binary file added .DS_Store
Binary file not shown.
62 changes: 62 additions & 0 deletions Dash/app.py
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 added FastAPI_App/.DS_Store
Binary file not shown.
21 changes: 21 additions & 0 deletions FastAPI_App/Dockerfile
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 added FastAPI_App/app/.DS_Store
Binary file not shown.
Empty file added FastAPI_App/app/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions FastAPI_App/app/main.py
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())
8 changes: 8 additions & 0 deletions FastAPI_App/docker-compose.yml
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
2 changes: 2 additions & 0 deletions FastAPI_App/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fastapi
uvicorn
Empty file added FastAPI_App/test.py
Empty file.
18 changes: 0 additions & 18 deletions Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions hello.py

This file was deleted.

5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions test_hello.py

This file was deleted.

0 comments on commit afc65ce

Please sign in to comment.