A Flask-based web application that allows users to create, view, and delete notes using MongoDB as the database backend.
- Create notes with CWID and full name
- View all notes in a responsive grid layout
- Delete notes
- Input validation
- Responsive design
- Flash messages for user feedback
- MongoDB integration
- Python 3.8+
- MongoDB (local installation or MongoDB Atlas account)
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/spicy/mongo-notes-flask-app cd mongo-notes-flask-app
-
Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate
-
Install required packages:
pip install -r requirements.txt
-
Create a
.env
file in the project root:MONGODB_URI=mongodb://localhost:27017/mongo-notes-flask-app SECRET_KEY=your-secure-secret-key-here FLASK_DEBUG=False
-
Local MongoDB:
- Install MongoDB on your system
- Start the MongoDB service
- Use the default connection string:
mongodb://localhost:27017/mongo-notes-flask-app
-
MongoDB Atlas:
- Create a MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Replace the MONGODB_URI in
.env
with your Atlas connection string
MONGODB_URI
: MongoDB connection stringSECRET_KEY
: Secret key for Flask sessionsFLASK_DEBUG
: Set to "True" for development, "False" for production
mongo-notes-flask-app/
├── app.py # Main Flask application
├── templates/ # HTML templates
│ └── home.html # Main template file
├── .env # Environment variables
├── requirements.txt # Project dependencies
└── README.md # Project documentation
-
Ensure MongoDB is running (if using local installation)
-
Start the Flask application:
python app.py
-
Access the application at
http://localhost:5000
- Fill in the required fields:
- CWID (8 digits)
- Full Name
- Note Content
- Click "Add Note"
- All notes are displayed on the homepage
- Notes are sorted by creation date (newest first)
- Find the note you want to delete
- Click the "Delete" button
- Confirm the deletions
- CWID must be 9 digits
- All fields are required
- Input is sanitized before storage
Returns all notes in JSON format
Response format:
{
"notes": [
{
"id": "note_id",
"cwid": "123456789",
"full_name": "John Doe",
"content": "Note content",
"created_at": "timestamp",
"updated_at": "timestamp"
}
]
}
- Invalid input validation
- Database connection errors
- Note not found errors
- Server errors
- Input validation and sanitization
- CSRF protection
- Secure session handling
- Environment variable configuration
Set FLASK_DEBUG=True
in .env
file