Flaskr is a simple blog application built using Flask, a lightweight web framework for Python. This project demonstrates the use of Flask for building web applications, following best practices for structuring a Flask project, handling routes, managing templates, and interacting with a SQLite database.
- Table of Contents
- Features
- Requirements
- Installation
- Usage
- Configuration
- Testing
- Contributing
- License
- Acknowledgements
- User authentication (registration and login)
- Create, edit, delete, and view blog posts
- Database integration with SQLite
- Templating with Jinja2
- Unit testing with pytest
- Python 3.6 or higher
- Flask 2.0.1 or higher
- SQLite 3.32 or higher
To get started with Flaskr, clone the repository and set up the environment:
git clone https://github.com/gomesluiz/flaskr.git
cd flaskr
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
To run the application locally, use the following commands:
-
Initialize the database:
flask init-db
-
Start the development server:
flask run
By default, the application will be available at http://127.0.0.1:5000
.
Flaskr uses a configuration file for settings. You can modify the config.py
file to change the configuration settings, such as the database path or debug mode.
import os
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'your_secret_key'
DATABASE = os.path.join(os.getcwd(), 'flaskr.sqlite')
To run the tests for Flaskr, use the following command:
pytest
Make sure to have pytest
installed in your virtual environment.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
Please ensure your code follows the project's coding standards and includes relevant tests.
This project is licensed under the MIT License. See the LICENSE file for more details.
- Flask framework: https://flask.palletsprojects.com/
- Bootstrap: https://getbootstrap.com/
- SQLite: https://www.sqlite.org/
For more detailed documentation and usage examples, please refer to the official documentation.