Skip to content

RobertoDure/flask_api_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Student API

This project is a RESTful API built with Flask for managing student records. It includes endpoints for creating, updating, retrieving, and deleting student records. The project uses SQLAlchemy for database interactions and Flasgger for API documentation.

Project Structure

  • app.py: The main application file containing the Flask app and route definitions.
  • config.py: Configuration file for database settings.
  • db_model.py: Contains the SQLAlchemy models for the database.
  • requirements.txt: A list of Python packages required for the project.

Setup

  1. Clone the repository:

    git clone https://github.com/RobertoDure/flask_api_example.git
    cd flask_api_example
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt
  4. Run the application:

    python app.py

Endpoints

  • POST /students: Create a new student.
  • PUT /students/<int:id>: Update an existing student.
  • GET /students/<int:id>: Get a student by ID.
  • GET /students: Get all students.
  • DELETE /students/<int:id>: Delete a student by ID.

Configuration

The database configuration is stored in config.py:

SQLALCHEMY_DATABASE_URI = 'sqlite:///students.db'

About

Flask API Example

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages