Spaces:
Sleeping
Sleeping
Update README
Browse files- README.md +14 -13
- app/main.py +4 -1
README.md
CHANGED
|
@@ -15,14 +15,15 @@ Endpoints
|
|
| 15 |
### `/`
|
| 16 |
|
| 17 |
* **Method:** GET
|
| 18 |
-
* **Description:**
|
| 19 |
-
* **Response:**
|
|
|
|
| 20 |
|
| 21 |
### `/random`
|
| 22 |
|
| 23 |
* **Method:** GET
|
| 24 |
* **Description:** Returns a random float between 0 and 1.
|
| 25 |
-
* **Response:**
|
| 26 |
* **Errors:**
|
| 27 |
+ `500 Internal Server Error`: If an error occurs while generating the random float.
|
| 28 |
|
|
@@ -30,21 +31,21 @@ Endpoints
|
|
| 30 |
|
| 31 |
* **Method:** GET
|
| 32 |
* **Description:** Returns a random integer.
|
| 33 |
-
* **Response:**
|
| 34 |
* **Errors:**
|
| 35 |
+ `500 Internal Server Error`: If an error occurs while generating the random integers.
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
-
### `/random/
|
| 41 |
|
| 42 |
* **Method:** GET
|
| 43 |
* **Description:** Returns a random integer within the specified range.
|
| 44 |
* **Parameters:**
|
| 45 |
+ `left`: The minimum value of the range (inclusive).
|
| 46 |
+ `right`: The maximum value of the range (inclusive).
|
| 47 |
-
* **Response:**
|
| 48 |
* **Errors:**
|
| 49 |
+ `400 Bad Request`: If `left` is greater than `right`.
|
| 50 |
+ `500 Internal Server Error`: If an error occurs while generating the random integer.
|
|
@@ -54,7 +55,7 @@ Endpoints
|
|
| 54 |
|
| 55 |
* **Method:** GET
|
| 56 |
* **Description:** Returns a random ASCII character.
|
| 57 |
-
* **Response:**
|
| 58 |
* **Errors:**
|
| 59 |
+ `500 Internal Server Error`: If an error occurs while generating the random character.
|
| 60 |
|
|
@@ -63,18 +64,18 @@ Endpoints
|
|
| 63 |
|
| 64 |
* **Method:** GET
|
| 65 |
* **Description:** Simulates a coin toss and returns the result.
|
| 66 |
-
* **Response:**
|
| 67 |
* **Errors:**
|
| 68 |
+ `500 Internal Server Error`: If an error occurs while simulating the coin toss.
|
| 69 |
|
| 70 |
|
| 71 |
-
### `/random/
|
| 72 |
|
| 73 |
* **Method:** GET
|
| 74 |
* **Description:** Selects a random option from the given list.
|
| 75 |
* **Parameters:**
|
| 76 |
+ `options`: A JSON-encoded list of options.
|
| 77 |
-
* **Response:**
|
| 78 |
* **Errors:**
|
| 79 |
+ `400 Bad Request`: If `options` is an empty list or not a valid JSON-encoded list.
|
| 80 |
+ `500 Internal Server Error`: If an error occurs while selecting the random option.
|
|
@@ -84,7 +85,7 @@ Endpoints
|
|
| 84 |
|
| 85 |
* **Method:** GET
|
| 86 |
* **Description:** Returns a random hex color.
|
| 87 |
-
* **Response:**
|
| 88 |
* **Errors:**
|
| 89 |
+ `500 Internal Server Error`: If an error occurs while generating the random color.
|
| 90 |
|
|
@@ -93,7 +94,7 @@ Endpoints
|
|
| 93 |
|
| 94 |
* **Method:** GET
|
| 95 |
* **Description:** Generates a random user with name, email, and password.
|
| 96 |
-
* **Response:**
|
| 97 |
* **Errors:**
|
| 98 |
+ `500 Internal Server Error`: If an error occurs while generating the random user data.
|
| 99 |
|
|
@@ -104,7 +105,7 @@ Endpoints
|
|
| 104 |
* **Description:** Generates a random password of the specified length.
|
| 105 |
* **Parameters:**
|
| 106 |
+ `length`: The length of the password.
|
| 107 |
-
* **Response:**
|
| 108 |
* **Errors:**
|
| 109 |
+ `400 Bad Request`: If `length` is less than 1.
|
| 110 |
+ `500 Internal Server Error`: If an error occurs while generating the random password.
|
|
|
|
| 15 |
### `/`
|
| 16 |
|
| 17 |
* **Method:** GET
|
| 18 |
+
* **Description:** Server status
|
| 19 |
+
* **Response:** {"message": "Server is running"}
|
| 20 |
+
|
| 21 |
|
| 22 |
### `/random`
|
| 23 |
|
| 24 |
* **Method:** GET
|
| 25 |
* **Description:** Returns a random float between 0 and 1.
|
| 26 |
+
* **Response:** `{"float": <random_float>}`
|
| 27 |
* **Errors:**
|
| 28 |
+ `500 Internal Server Error`: If an error occurs while generating the random float.
|
| 29 |
|
|
|
|
| 31 |
|
| 32 |
* **Method:** GET
|
| 33 |
* **Description:** Returns a random integer.
|
| 34 |
+
* **Response:** `{"int": <random_int>}`
|
| 35 |
* **Errors:**
|
| 36 |
+ `500 Internal Server Error`: If an error occurs while generating the random integers.
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
+
### `/random/{left}/{right}`
|
| 42 |
|
| 43 |
* **Method:** GET
|
| 44 |
* **Description:** Returns a random integer within the specified range.
|
| 45 |
* **Parameters:**
|
| 46 |
+ `left`: The minimum value of the range (inclusive).
|
| 47 |
+ `right`: The maximum value of the range (inclusive).
|
| 48 |
+
* **Response:** `{"int": <random_int>}`
|
| 49 |
* **Errors:**
|
| 50 |
+ `400 Bad Request`: If `left` is greater than `right`.
|
| 51 |
+ `500 Internal Server Error`: If an error occurs while generating the random integer.
|
|
|
|
| 55 |
|
| 56 |
* **Method:** GET
|
| 57 |
* **Description:** Returns a random ASCII character.
|
| 58 |
+
* **Response:** `{"char": <random_char>}`
|
| 59 |
* **Errors:**
|
| 60 |
+ `500 Internal Server Error`: If an error occurs while generating the random character.
|
| 61 |
|
|
|
|
| 64 |
|
| 65 |
* **Method:** GET
|
| 66 |
* **Description:** Simulates a coin toss and returns the result.
|
| 67 |
+
* **Response:** `{"result": "Heads" or "Tails"}`
|
| 68 |
* **Errors:**
|
| 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.
|
| 76 |
* **Parameters:**
|
| 77 |
+ `options`: A JSON-encoded list of options.
|
| 78 |
+
* **Response:** `{"selected": <random_option>}`
|
| 79 |
* **Errors:**
|
| 80 |
+ `400 Bad Request`: If `options` is an empty list or not a valid JSON-encoded list.
|
| 81 |
+ `500 Internal Server Error`: If an error occurs while selecting the random option.
|
|
|
|
| 85 |
|
| 86 |
* **Method:** GET
|
| 87 |
* **Description:** Returns a random hex color.
|
| 88 |
+
* **Response:** `{"color": <random_color>}`
|
| 89 |
* **Errors:**
|
| 90 |
+ `500 Internal Server Error`: If an error occurs while generating the random color.
|
| 91 |
|
|
|
|
| 94 |
|
| 95 |
* **Method:** GET
|
| 96 |
* **Description:** Generates a random user with name, email, and password.
|
| 97 |
+
* **Response:** `{"name": <random_name>, "email": <random_email>, "password": <random_password>}`
|
| 98 |
* **Errors:**
|
| 99 |
+ `500 Internal Server Error`: If an error occurs while generating the random user data.
|
| 100 |
|
|
|
|
| 105 |
* **Description:** Generates a random password of the specified length.
|
| 106 |
* **Parameters:**
|
| 107 |
+ `length`: The length of the password.
|
| 108 |
+
* **Response:** `{"password": <random_password>}`
|
| 109 |
* **Errors:**
|
| 110 |
+ `400 Bad Request`: If `length` is less than 1.
|
| 111 |
+ `500 Internal Server Error`: If an error occurs while generating the random password.
|
app/main.py
CHANGED
|
@@ -6,4 +6,7 @@ app.include_router(randoom_router)
|
|
| 6 |
|
| 7 |
@app.get("/")
|
| 8 |
def get_home() -> dict:
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
@app.get("/")
|
| 8 |
def get_home() -> dict:
|
| 9 |
+
"""
|
| 10 |
+
Return server status
|
| 11 |
+
"""
|
| 12 |
+
return Response("Server is running")
|