This project is a simple blog application built using the Flask framework. It provides functionality for viewing blog posts, as well as an admin dashboard for managing posts, uploading files, and handling user contact forms. The application uses SQLAlchemy for database management and Flask-Mail for sending email notifications.
- Home Page: Displays a paginated list of blog posts.
- Blog Post Page: View the content of a specific blog post.
- About Page: Static page with information about the blog.
- Admin Dashboard: Manage blog posts, including adding, editing, and deleting posts.
- File Upload: Upload files to the server.
- Contact Form: Send messages to the admin via email.
- User Authentication: Secure admin access with a username and password.
- Python 3.x
- Virtual Environment (recommended)
- SQLite (default, included with Python)
- Flask-Mail Configuration (Gmail account)
-
Clone the Repository
git clone https://github.com/yourusername/flask-blog-app.git cd flask-blog-app -
Create and Activate a Virtual Environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies
pip install -r requirements.txt
-
Set Up Configuration
- Open the
config.jsonfile and update the following fields with your own information:local_uri: Local database URI (e.g.,sqlite:///site.db).prod_uri: Production database URI (optional).upload_location: Path where uploaded files will be stored.gmail-user: Your Gmail username for sending emails.gmail-password: Your Gmail password.admin_user: Admin username for accessing the dashboard.admin_password: Admin password for accessing the dashboard.
- Open the
-
Run the Application
python app.py
The application will run in debug mode and can be accessed at
http://127.0.0.1:5000/.
-
Access the Application
Open your browser and navigate to
http://127.0.0.1:5000. -
Admin Dashboard
- Navigate to
/dashboardto log in as an admin. - Use the credentials specified in
config.json. - From the dashboard, you can add, edit, or delete blog posts.
- Navigate to
-
File Uploads
- Navigate to
/uploaderas an admin to upload files. Files will be saved in the directory specified inconfig.jsonunderupload_location.
- Navigate to
-
Contact Form
- Navigate to
/contactto send a message to the admin. The message will be emailed to the admin's Gmail account.
- Navigate to
Contributions are welcome! Feel free to open an issue or submit a pull request if you have any suggestions, bug fixes, or improvements.
This project is licensed under the MIT License. See the LICENSE file for more details.
