Skip to content

Commit

Permalink
feat: add route for diceroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyvy-vi committed Aug 10, 2021
1 parent 0ec031e commit f76f213
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions routes/diceroll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random
from fastapi import APIRouter, Query

router = APIRouter()


@router.get("/diceroll")
def roll_dice(
num: int = Query(1, ge=1, le=10000),
sides: int = Query(6, ge=3, le=10000)
):
return {
"task": f"diceroll - d{sides} x {num}",
"result": random.choices(
range(1, sides + 1),
k = num
)
}

0 comments on commit f76f213

Please sign in to comment.