Skip to content

Commit e7e35bf

Browse files
committed
Add new-assignment prompt
1 parent 8287362 commit e7e35bf

4 files changed

Lines changed: 120 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
agent: agent
3+
description: Create a new programming homework assignment
4+
argument-hint: Provide assignment details
5+
---
6+
7+
# Create New Programming Assignment
8+
9+
Your goal is to generate a new homework assignment for the Mergington High School students.
10+
11+
## Step 1: Gather Assignment Information
12+
13+
If not already provided by the user, ask what the assignment will be about.
14+
15+
## Step 2: Create Assignment Structure
16+
17+
1. Create a new directory in the `assignments` folder with a unique name based on the assignment topic
18+
1. Create a new file in the directory named `README.md` with the structure from the [assignment-template.md](../../templates/assignment-template.md) file
19+
1. Fill out the assignment details in the README file
20+
1. (Optional) Add starter code or attachments if the assignment needs them - add these files to the same assignment folder
21+
22+
## Step 3: Update Website Configuration
23+
24+
Update the assignments list in [config.json](../../config.json) website configuration file to include the new assignment. For the dueDate field, use the current date plus 7 days unless specified otherwise.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 📘 Assignment: Building REST APIs with FastAPI
2+
3+
## 🎯 Objective
4+
5+
Learn to build a RESTful API using the FastAPI framework, including creating endpoints, handling HTTP methods, and working with request/response models.
6+
7+
## 📝 Tasks
8+
9+
### 🛠️ Create a Todo List API
10+
11+
#### Description
12+
Build a REST API for managing a todo list with endpoints to create, read, update, and delete todo items.
13+
14+
#### Requirements
15+
Completed program should:
16+
17+
- Define a Todo model with fields: id, title, description, and completed status
18+
- Create a GET endpoint to retrieve all todos
19+
- Create a GET endpoint to retrieve a single todo by ID
20+
- Create a POST endpoint to add a new todo
21+
- Create a PUT endpoint to update an existing todo
22+
- Create a DELETE endpoint to remove a todo
23+
- Return appropriate HTTP status codes (200, 201, 404, etc.)
24+
- Use FastAPI's automatic API documentation at /docs
25+
26+
27+
### 🛠️ Add Data Validation
28+
29+
#### Description
30+
Implement request validation using Pydantic models to ensure data integrity.
31+
32+
#### Requirements
33+
Completed program should:
34+
35+
- Use Pydantic models for request and response validation
36+
- Validate that title is required and not empty
37+
- Validate that completed is a boolean value
38+
- Return clear error messages for invalid input (422 status)
39+
- Include example values in the API documentation
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
REST API with FastAPI - Starter Code
3+
4+
This starter code provides a basic FastAPI application structure.
5+
Your task is to implement the todo list API endpoints.
6+
7+
To run this application:
8+
1. Install FastAPI and uvicorn: pip install fastapi uvicorn
9+
2. Run the server: uvicorn starter-code:app --reload
10+
3. Visit http://localhost:8000/docs to see the API documentation
11+
"""
12+
13+
from fastapi import FastAPI, HTTPException
14+
from pydantic import BaseModel
15+
from typing import List, Optional
16+
17+
app = FastAPI(title="Todo List API", version="1.0.0")
18+
19+
# TODO: Define your Pydantic models here
20+
# Example:
21+
# class Todo(BaseModel):
22+
# id: int
23+
# title: str
24+
# description: Optional[str] = None
25+
# completed: bool = False
26+
27+
28+
# In-memory storage for todos (replace with database in production)
29+
todos = []
30+
31+
32+
@app.get("/")
33+
def read_root():
34+
"""Welcome endpoint"""
35+
return {"message": "Welcome to the Todo List API! Visit /docs for documentation."}
36+
37+
38+
# TODO: Implement your API endpoints here
39+
# GET /todos - Get all todos
40+
# GET /todos/{todo_id} - Get a specific todo
41+
# POST /todos - Create a new todo
42+
# PUT /todos/{todo_id} - Update a todo
43+
# DELETE /todos/{todo_id} - Delete a todo

config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@
5858
"type": "csv"
5959
}
6060
]
61+
},
62+
{
63+
"id": "rest-api-fastapi",
64+
"title": "Building REST APIs with FastAPI",
65+
"description": "Learn to build RESTful APIs using the FastAPI framework",
66+
"path": "assignments/rest-api-fastapi",
67+
"dueDate": "2026-01-28",
68+
"attachments": [
69+
{
70+
"name": "Starter Code",
71+
"file": "starter-code.py",
72+
"type": "python"
73+
}
74+
]
6175
}
6276
]
6377
}

0 commit comments

Comments
 (0)