This is a practice project for learning Python and REST APIs. You'll create a simple API that returns information about Team 2658 E-motion.
- Team Number: 2658
- Team Name: E-motion
- Location: California
- Competition: FIRST Robotics Competition (FRC)
- Python basics (dictionaries, functions, conditionals)
- REST API concepts (routes, endpoints, JSON responses)
- Async programming basics (don't worry too much about this yet!)
- Testing APIs in the browser
Open app.py and complete these TODOs:
Replace the 0s and empty strings with real information:
- team_number: 2658
- team_name: E-motion
- school: Your school name
- city: Your city
- state: Your state
- founded_year: When was Team 2658 founded?
- Add more fields if you want! (team motto, colors, number of members, etc.)
- get_team(): Return all team data as JSON
- get_field(field): Return a specific field from team_data
- field_count(): Return the number of fields in team_data
# Create a virtual environment (optional but recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtpython app.pyThe API will start at http://localhost:5000
Open these URLs in your browser after completing the TODOs:
-
Home: http://localhost:5000/
- Should return:
{"message": "Welcome to Team 2658 API!"}
- Should return:
-
Get All Team Data: http://localhost:5000/team
- Should return: All the team_data dictionary as JSON
-
Get Specific Field: http://localhost:5000/info/team_name
- Should return: Just the team name
- Try other fields:
/info/team_number,/info/city, etc.
-
Count Fields: http://localhost:5000/count
- Should return: The number of fields in team_data
- Use
jsonify()to convert Python dictionaries to JSON responses - Check if a field exists before accessing it:
if field in team_data: - Use
len()to count items in a dictionary - The
asyncandawaitkeywords are for asynchronous programming (Quart's special feature)
CONTACT A LEAD
After completing this project, you can:
- Add more endpoints (e.g.,
/pathwaysto list the four pathways) - Add POST endpoints to update team data
- Connect this to a database
- Add authentication