This is a simple implementation of a Like Button feature
- Python 3.x
- Sqlite
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment and activate it:
python -m venv .venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the environment variables
SECRET_KEY=<your_secret_key> SQLALCHEMY_DATABASE_URI=<your_database_uri>
-
Run the application:
flask run
Key configurations include:
SECRET_KEY: this should be provided in the .env fileSQLALCHEMY_DATABASE_URI: Database connection URI (default: 'sqlite:///default.db')SESSION_TYPE: Session type (default:filesystem)SESSION_COOKIE_HTTPONLY: HTTPOnly flag for session cookies (default:True)SESSION_COOKIE_SECURE: Secure flag for session cookies (default:False)SESSION_PERMANENT: Permanent session flag (default:False)
The application provides the following endpoints:
- URL:
/auth/register - Method:
POST - Payload:
{ "username": "your_username", "email": "your_email", "password": "your_password" } - Response:
{ "message": "You've logged in successfully" }
- URL:
/auth/login - Method:
POST - Payload:
{ "email": "your_email", "password": "your_password" } - Response:
{ "message": "You've logged in successfully" }
- URL:
/post/new - Method:
POST - Payload:
{ "title": "Post Title", "content": "Post Content" } - Response:
{ "message": "Article created successfully", "data" { "article_id": "articleID" } }
- URL:
/like - Method:
POST - Payload:
{ "articleID": "article_id" } - Response:
{ "message": "Liked post" }