Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 47 of 55 · Python

Building a Simple REST API

Duration: 20 minutes

Building a Simple REST API\n\nFlask can also serve JSON APIs. Below we expose a /api/users endpoint that returns a list of user objects.\n\npython\nfrom flask import Flask, jsonify\n\napp = Flask(__name__)\n\nusers = [\n {'id': 1, 'name': 'Alice'},\n {'id': 2, 'name': 'Bob'}\n]\n\n@app.route('/api/users')\ndef get_users():\n return jsonify(users)\n\nif __name__ == '__main__':\n app.run(debug=True)\n\n\nVisit http://127.0.0.1:5000/api/users to see the JSON response. You can extend the API with POST, PUT, and DELETE methods for full CRUD support.\n

Previous: Introduction to Flask Web FrameworkNext: Database Access with SQLite