An open API service indexing awesome lists of open source software.

https://github.com/mammet-tech/lateshow-edwin-mammet

A Flask REST API to manage late show episodes, guests, and appearances. Built with SQLAlchemy, Flask-Migrate, and SQLite.
https://github.com/mammet-tech/lateshow-edwin-mammet

flask flask-migrate flask-sqlalchemy postman python sqlite

Last synced: 8 months ago
JSON representation

A Flask REST API to manage late show episodes, guests, and appearances. Built with SQLAlchemy, Flask-Migrate, and SQLite.

Awesome Lists containing this project

README

          

# ๐Ÿ“บ Late Show API

This is a RESTful API built with Flask for tracking guests and episodes on a late night show.

---

## ๐Ÿ“ Project Structure

```
.
โ”œโ”€โ”€ __pycache__/
โ”œโ”€โ”€ instance/
โ”‚ โ””โ”€โ”€ app.db
โ”œโ”€โ”€ migrations/
โ”‚ โ”œโ”€โ”€ versions/
โ”‚ โ”œโ”€โ”€ env.py
โ”‚ โ”œโ”€โ”€ README
โ”‚ โ””โ”€โ”€ script.py.mako
โ”œโ”€โ”€ venv/
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ models.py
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ requirements.txt
```

---

## โš™๏ธ Technologies Used

- Python 3.8+
- Flask
- Flask-SQLAlchemy
- Flask-Migrate
- SQLite
- Postman (for API testing)

---

## ๐Ÿš€ Setup Instructions

### 1. Clone the Repository

```bash
git clone https://git@github.com:Mammet-tech/lateshow-edwin-mammet.git
cd lateshow-edwin-mammet
```

### 2. Create Virtual Environment

```bash
pipenv install
pipenv shell
```

### 3. Set Flask Environment Variables

```bash
export FLASK_APP=app.py
export FLASK_RUN_PORT=5555
```

### 4. Run Migrations

```bash
flask db init
flask db migrate -m "Create tables"
flask db upgrade
```

### 5. Seed the Database

You may run your own `seed.py` or import the provided CSV file to populate the database.

---

## ๐Ÿงช API Endpoints

### โœ… GET /episodes

Returns all episodes:

```json
[
{
"id": 1,
"date": "1/11/99",
"number": 1
},

]
```

---

### โœ… GET /episodes/

Returns a single episode with its appearances:

```json
{
"id": 1,
"date": "1/11/99",
"number": 1,
"appearances": [
{
"id": 1,
"rating": 4,
"guest_id": 1,
"episode_id": 1,
"guest": {
"id": 1,
"name": "Michael J. Fox",
"occupation": "actor"
}
}
]
}
```

If not found:

```json
{
"error": "Episode not found"
}
```

---

### โœ… GET /guests

Returns all guests.

---

### โœ… POST /appearances

Creates a new guest appearance.

**Request Body**:

```json
{
"rating": 5,
"episode_id": 2,
"guest_id": 3
}
```

**Valid Response**:

```json
{
"id": 162,
"rating": 5,
"guest_id": 3,
"episode_id": 2,
"episode": {
"date": "1/12/99",
"id": 2,
"number": 2
},
"guest": {
"id": 3,
"name": "Tracey Ullman",
"occupation": "television actress"
}
}
```

**Validation Error**:

```json
{
"errors": ["validation errors"]
}
```

---

## ๐Ÿ“ฌ Testing in Postman

1. Open Postman
2. Import the provided Postman collection:
`challenge-4-lateshow.postman_collection.json`
3. Test all the endpoints using real or seed data.

---

## ๐Ÿง‘ Author

**Edwin Mammet**

---

## ๐Ÿ“„ License

This project is licensed under the MIT License.