File size: 3,654 Bytes
ce73693
 
 
 
 
 
 
 
 
7564cf9
ce73693
0ccafd5
339be2b
ce73693
339be2b
ce73693
339be2b
ce73693
339be2b
 
 
 
 
 
 
 
 
 
 
ce73693
 
 
339be2b
ce73693
339be2b
 
 
 
 
ce73693
 
 
 
 
339be2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce73693
 
 
 
339be2b
 
ce73693
 
 
339be2b
 
 
 
ce73693
339be2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: Sanjeev's Favorite Drinks
emoji: πŸ₯€
colorFrom: red
colorTo: purple
sdk: docker
app_file: app.py
pinned: false
---



# Sanjeev's Favorite Drink API πŸ₯€

This is a REST API with full CRUD (Create, Read, Update, Delete) operations that lets you manage a list of drinks. It is hosted on Hugging Face Spaces and serves as a fun way to access and explore my favorite drinks. 🍹

The API includes features such as retrieving the list of all drinks, getting details of a specific drink, adding new drinks, and deleting them. Note that due to the hosting limitations of Hugging Face Spaces, **POST** and **DELETE** operations are currently disabled. 🚫

---

## πŸ“‹ API Summary

| HTTP Method | Endpoint          | Description                                        |
|-------------|-------------------|----------------------------------------------------|
| **GET**     | `/`               | Returns a list of all drinks.                     |
| **GET**     | `/drinks`         | Same as `/`, returns all drinks.                  |
| **GET**     | `/drinks/<id>`    | Returns details of a specific drink by its ID.    |
| **POST**    | `/drinks`         | Add a new drink (not supported on Hugging Face).  |
| **DELETE**  | `/drinks/<id>`    | Delete a drink (not supported on Hugging Face).   |

---

## πŸ“˜ Database Design

| Column       | Type      | Description                               |
|--------------|-----------|-------------------------------------------|
| **id**       | INTEGER   | Unique identifier (Primary Key).          |
| **name**     | STRING(80)| Name of the drink (must be unique).        |
| **description** | STRING(120) | Short description of the drink.          |

---

## πŸš€ How It Works

The API uses Flask and SQLAlchemy. The data is stored in a SQLite database. πŸ›  Flask handles the incoming HTTP requests, queries the database, and returns the corresponding responses. CRUD operations can be performed locally, while only **GET** operations are supported on Hugging Face Spaces due to the read-only database restrictions. πŸ“‚

---

## πŸ–±οΈ Usage Instructions

### 1️⃣ View All Drinks
**Method**: `GET`  
**URL**: [https://sanjeevb1-drinks.hf.space/drinks](https://sanjeevb1-drinks.hf.space/drinks)  

**Example Response**:  
```json
{
    "drinks": [
        {
            "name": "Diet Coke",
            "description": "Tastes like Coke with no calories, great!!!"
        },
        {
            "name": "Fanta",
            "description": "Like the taste and color of it"
        }
    ]
}
```

---

### 2️⃣ View a Specific Drink
**Method**: `GET`  
**URL**: [https://sanjeevb1-drinks.hf.space/drinks/1](https://sanjeevb1-drinks.hf.space/drinks/1)  

**Example Response**:  
```json
{
    "name": "Diet Coke",
    "description": "Tastes like Coke with no calories, great!!!"
}
```

---

### 3️⃣ Add a New Drink (🚫 Not Supported on Hugging Face Spaces)
**Method**: `POST`  
**URL**: `/drinks`  
**Body (JSON)**:  
```json
{
    "name": "Mango Juice",
    "description": "Sweet and refreshing"
}
```

---

### 4️⃣ Delete a Drink (🚫 Not Supported on Hugging Face Spaces)
**Method**: `DELETE`  
**URL**: `/drinks/1`

---

## πŸ›‘ Note

⚠️ **POST** and **DELETE** requests won't work on Hugging Face Spaces because the database is read-only. You can clone this repository and run it locally to enable all CRUD operations. πŸ’»

---

## πŸ‘€ Author

Sanjeev's Favorite Drinks API is designed to provide an interactive experience with REST API operations while sharing a taste of my favorite drinks. 🍹 Cheers! πŸ₯‚
```

Let me know if you need further adjustments! 😊