Skip to content

Commit

Permalink
feat: add dice rolling endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gmontanola committed May 20, 2024
1 parent ddb0468 commit a41e4e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
--include-tools \
--layout=packed
- name: Build and push deps
if: steps.build-deps-pex.outputs.cache-hit != 'true'
if: steps.cache-deps.outputs.cache-hit != 'true'
id: build-deps-docker
uses: docker/build-push-action@v5
with:
Expand All @@ -72,7 +72,7 @@ jobs:
pex -o build/src.pex --include-tools \
--layout=packed -P ${{ env.APP_NAME }}
- name: Build and push src
if: steps.build-src-pex.outputs.cache-hit != 'true'
if: steps.cache-src.outputs.cache-hit != 'true'
uses: docker/build-push-action@v5
id: build-src-docker
with:
Expand Down
7 changes: 7 additions & 0 deletions appex/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import random

from fastapi import Depends, FastAPI, HTTPException
from sqlalchemy.orm import Session

Expand All @@ -23,6 +25,11 @@ async def root() -> dict[str, str]:
return {"message": "👋 🌎"}


@app.get("/dice/")
async def dice(sides: int = 6) -> dict[str, int]:
return {"🎲": random.randint(1, sides)}


@app.post("/users/", response_model=schemas.User)
def create_user(user: schemas.UserCreate, db: Session = Depends(get_db)):
db_user = crud.get_user_by_email(db, email=user.email)
Expand Down

0 comments on commit a41e4e7

Please sign in to comment.