Salahin commited on
Commit
f3a3fd7
·
1 Parent(s): ebde93e

Fix issues by reordering routes

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. app/routers/random.py +2 -2
  3. app/utils/utils.py +4 -1
README.md CHANGED
@@ -38,7 +38,7 @@ Endpoints
38
 
39
 
40
 
41
- ### `/random/{left}/{right}`
42
 
43
  * **Method:** GET
44
  * **Description:** Returns a random integer within the specified range.
@@ -69,7 +69,7 @@ Endpoints
69
  + `500 Internal Server Error`: If an error occurs while simulating the coin toss.
70
 
71
 
72
- ### `/random/{options}`
73
 
74
  * **Method:** GET
75
  * **Description:** Selects a random option from the given list.
 
38
 
39
 
40
 
41
+ ### `/random/int/{left}/{right}`
42
 
43
  * **Method:** GET
44
  * **Description:** Returns a random integer within the specified range.
 
69
  + `500 Internal Server Error`: If an error occurs while simulating the coin toss.
70
 
71
 
72
+ ### `/random/select/{options}`
73
 
74
  * **Method:** GET
75
  * **Description:** Selects a random option from the given list.
app/routers/random.py CHANGED
@@ -19,7 +19,7 @@ def get_random_int() -> dict:
19
  return {"int": random_int()}
20
 
21
 
22
- @router.get("/{left}/{right}")
23
  def get_random_in_range(left: int, right: int) -> dict:
24
  """Return a random integer within the given range."""
25
  if left > right:
@@ -39,7 +39,7 @@ def toss_coin() -> dict:
39
  return {"result": random_choice(["Heads", "Tails"])}
40
 
41
 
42
- @router.get("/{options}")
43
  def get_random_option(options: str) -> dict:
44
  """Select a random option from the given list."""
45
  options_list = json.loads(options)
 
19
  return {"int": random_int()}
20
 
21
 
22
+ @router.get("/int/{left}/{right}")
23
  def get_random_in_range(left: int, right: int) -> dict:
24
  """Return a random integer within the given range."""
25
  if left > right:
 
39
  return {"result": random_choice(["Heads", "Tails"])}
40
 
41
 
42
+ @router.get("/select/{options}")
43
  def get_random_option(options: str) -> dict:
44
  """Select a random option from the given list."""
45
  options_list = json.loads(options)
app/utils/utils.py CHANGED
@@ -7,9 +7,12 @@ def random_int(l: int = 0, r: int = 10**3) -> int:
7
  """Generate a random integer within the given range."""
8
  return randint(l, r)
9
 
10
- def random_float()->float:
 
11
  """Generate a random float number."""
12
  return random()
 
 
13
  def random_choice(options: list):
14
  """Generate a random choice from a list of options."""
15
  return choice(options)
 
7
  """Generate a random integer within the given range."""
8
  return randint(l, r)
9
 
10
+
11
+ def random_float() -> float:
12
  """Generate a random float number."""
13
  return random()
14
+
15
+
16
  def random_choice(options: list):
17
  """Generate a random choice from a list of options."""
18
  return choice(options)