Skip to content

Commit 7c5d952

Browse files
author
Kendall Roden
committed
python checkin
1 parent d5d64c8 commit 7c5d952

File tree

6 files changed

+313
-0
lines changed

6 files changed

+313
-0
lines changed

.gitignore

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
2+
3+
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,python
4+
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,python
5+
6+
### macOS ###
7+
# General
8+
.DS_Store
9+
.AppleDouble
10+
.LSOverride
11+
12+
# Icon must end with two \r
13+
Icon
14+
15+
# Thumbnails
16+
._*
17+
18+
# Files that might appear in the root of a volume
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
27+
# Directories potentially created on remote AFP share
28+
.AppleDB
29+
.AppleDesktop
30+
Network Trash Folder
31+
Temporary Items
32+
.apdisk
33+
34+
### macOS Patch ###
35+
# iCloud generated files
36+
*.icloud
37+
38+
### Python ###
39+
# Byte-compiled / optimized / DLL files
40+
__pycache__/
41+
*.py[cod]
42+
*$py.class
43+
44+
# C extensions
45+
*.so
46+
47+
# Distribution / packaging
48+
.Python
49+
build/
50+
develop-eggs/
51+
dist/
52+
downloads/
53+
eggs/
54+
.eggs/
55+
lib/
56+
lib64/
57+
parts/
58+
sdist/
59+
var/
60+
wheels/
61+
share/python-wheels/
62+
*.egg-info/
63+
.installed.cfg
64+
*.egg
65+
MANIFEST
66+
67+
# PyInstaller
68+
# Usually these files are written by a python script from a template
69+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
70+
*.manifest
71+
*.spec
72+
73+
# Installer logs
74+
pip-log.txt
75+
pip-delete-this-directory.txt
76+
77+
# Unit test / coverage reports
78+
htmlcov/
79+
.tox/
80+
.nox/
81+
.coverage
82+
.coverage.*
83+
.cache
84+
nosetests.xml
85+
coverage.xml
86+
*.cover
87+
*.py,cover
88+
.hypothesis/
89+
.pytest_cache/
90+
cover/
91+
92+
# Translations
93+
*.mo
94+
*.pot
95+
96+
# Django stuff:
97+
*.log
98+
local_settings.py
99+
db.sqlite3
100+
db.sqlite3-journal
101+
102+
# Flask stuff:
103+
instance/
104+
.webassets-cache
105+
106+
# Scrapy stuff:
107+
.scrapy
108+
109+
# Sphinx documentation
110+
docs/_build/
111+
112+
# PyBuilder
113+
.pybuilder/
114+
target/
115+
116+
# Jupyter Notebook
117+
.ipynb_checkpoints
118+
119+
# IPython
120+
profile_default/
121+
ipython_config.py
122+
123+
# pyenv
124+
# For a library or package, you might want to ignore these files since the code is
125+
# intended to run in multiple environments; otherwise, check them in:
126+
# .python-version
127+
128+
# pipenv
129+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
130+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
131+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
132+
# install all needed dependencies.
133+
#Pipfile.lock
134+
135+
# poetry
136+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
137+
# This is especially recommended for binary packages to ensure reproducibility, and is more
138+
# commonly ignored for libraries.
139+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
140+
#poetry.lock
141+
142+
# pdm
143+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
144+
#pdm.lock
145+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
146+
# in version control.
147+
# https://pdm.fming.dev/#use-with-ide
148+
.pdm.toml
149+
150+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
151+
__pypackages__/
152+
153+
# Celery stuff
154+
celerybeat-schedule
155+
celerybeat.pid
156+
157+
# SageMath parsed files
158+
*.sage.py
159+
160+
# Environments
161+
.env
162+
.venv
163+
env/
164+
venv/
165+
ENV/
166+
env.bak/
167+
venv.bak/
168+
169+
# Spyder project settings
170+
.spyderproject
171+
.spyproject
172+
173+
# Rope project settings
174+
.ropeproject
175+
176+
# mkdocs documentation
177+
/site
178+
179+
# mypy
180+
.mypy_cache/
181+
.dmypy.json
182+
dmypy.json
183+
184+
# Pyre type checker
185+
.pyre/
186+
187+
# pytype static type analyzer
188+
.pytype/
189+
190+
# Cython debug symbols
191+
cython_debug/
192+
193+
# PyCharm
194+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
195+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
196+
# and can be added to the global gitignore or merged into this file. For a more nuclear
197+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
198+
#.idea/
199+
200+
### VisualStudioCode ###
201+
.vscode/*
202+
!.vscode/settings.json
203+
!.vscode/tasks.json
204+
!.vscode/launch.json
205+
!.vscode/extensions.json
206+
!.vscode/*.code-snippets
207+
208+
# Local History for Visual Studio Code
209+
.history/
210+
211+
# Built Visual Studio Code Extensions
212+
*.vsix
213+
214+
### VisualStudioCode Patch ###
215+
# Ignore all local history of files
216+
.history
217+
.ionide
218+
219+
# Support for Project snippet scope
220+
.vscode/*.code-snippets
221+
222+
# Ignore code-workspaces
223+
*.code-workspace
224+
225+
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,python
226+
227+
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
228+

.vscode/launch.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Album API",
6+
"type": "python",
7+
"request": "launch",
8+
"module": "uvicorn",
9+
"cwd": "${workspaceFolder}/src",
10+
"args": ["app.main:app", "--port", "3000", "--reload"]
11+
}
12+
]
13+
}

.vscode/tasks.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Start Album API",
6+
"type": "shell",
7+
"command": "uvicorn app.main:app --port 3000 --reload",
8+
"options": {
9+
"cwd": "${workspaceFolder}/src"
10+
},
11+
"presentation": {
12+
"panel": "dedicated"
13+
},
14+
"problemMatcher": []
15+
}
16+
]
17+
}

src/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
FROM python:3.9
3+
4+
WORKDIR /code
5+
6+
COPY ./requirements.txt /code/requirements.txt
7+
8+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9+
10+
COPY ./app /code/app
11+
12+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]

src/app/main.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from typing import Optional
2+
3+
from fastapi import FastAPI
4+
from fastapi.middleware.cors import CORSMiddleware
5+
6+
app = FastAPI()
7+
8+
app.add_middleware(
9+
CORSMiddleware,
10+
allow_origins=["*"],
11+
allow_credentials=True,
12+
allow_methods="GET",
13+
allow_headers=["*"]
14+
)
15+
16+
class Album():
17+
def __init__(self, id, title, artist, price, image_url):
18+
self.id = id
19+
self.title = title
20+
self.artist = artist
21+
self.price = price
22+
self.image_url = image_url
23+
24+
albums = [
25+
Album(1, "Sgt Peppers Lonely Hearts Club Band", "The Beatles", 10.99, "https://www.listchallenges.com/f/items/f3b05a20-31ae-4fdf-aebd-d1515af54eea.jpg"),
26+
Album(2, "Pet Sounds", "The Beach Boys", 13.99, "https://www.listchallenges.com/f/items/fdef1440-e979-455a-90a7-14e77fac79af.jpg"),
27+
Album(3, "The Beatles: Revolver", "The Beatles", 13.99, "https://www.listchallenges.com/f/items/19ff786d-d7a4-4fdc-bee2-59db8b33370d.jpg"),
28+
Album(4, "Highway 61 Revisited", "Bob Dylan", 12.99,"https://www.listchallenges.com/f/items/428cf087-6c24-45ad-bf8c-bd3c57ddf444.jpg"),
29+
Album(5, "Rubber Soul", "The Beatles", 12.99, "https://www.listchallenges.com/f/items/ebc794ef-1491-4672-a007-0081edc1a8ae.jpg"),
30+
Album(6, "What's Going On", "Marvin Gaye", 14.99, "https://www.listchallenges.com/f/items/e5250d6c-1c15-4617-a943-b27e87e21704.jpg")
31+
]
32+
33+
@app.get("/")
34+
def read_root():
35+
return {"Azure Container Apps Python Sample API"}
36+
37+
38+
@app.get("/albums")
39+
def get_albums():
40+
return albums

src/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fastapi>=0.68.0,<0.69.0
2+
pydantic>=1.8.0,<2.0.0
3+
uvicorn>=0.15.0,<0.16.0

0 commit comments

Comments
 (0)