-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mypy_core_auth
- Loading branch information
Showing
10 changed files
with
92 additions
and
13 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
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
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,11 @@ | ||
FROM python:3.9 | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install fastapi[standard] redis | ||
|
||
COPY ./app /app | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["fastapi", "run", "main.py", "--port", "80"] |
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,30 @@ | ||
# This app will use redis to store given key-value pairs. | ||
|
||
import os | ||
import redis | ||
|
||
from fastapi import FastAPI | ||
|
||
|
||
app = FastAPI() | ||
|
||
redis_host = os.getenv("REDIS_HOST") | ||
redis_port = os.getenv("REDIS_PORT") | ||
redis_client = redis.Redis(host=redis_host, port=redis_port) | ||
redis_client.ping() | ||
|
||
|
||
@app.get("/") | ||
def health_check(): | ||
return {"status": "ok"} | ||
|
||
|
||
@app.get("/get/{key}") | ||
def read_item(key: str): | ||
return {key: redis_client.get(key)} | ||
|
||
|
||
@app.post("/set") | ||
def create_item(key: str, value: str): | ||
redis_client.set(key, value) | ||
return {key: value} |
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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