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.
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.
-
Clone the repository:
git clone https://github.com/RobertoDure/flask_api_example.git cd flask_api_example -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Run the application:
python app.py
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.
The database configuration is stored in config.py:
SQLALCHEMY_DATABASE_URI = 'sqlite:///students.db'