HaHaHub is a web application that allows users to submit, view, and vote on jokes. It features user authentication, an admin dashboard, and an API for joke retrieval and voting. The application is currently hosted at hahahub.bhavya31.hackclub.app.
git clone https://github.com/yourusername/HaHaHub.git
cd HaHaHub
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
python setup_db.py
python app.py
The app will be available at http://127.0.0.1:5080/.
Endpoint: /api/joke
Method: GET
Response:
{
"id": 1,
"joke": "Why don’t skeletons fight each other? They don’t have the guts."
}
Curl Command:
curl -X GET https://hahahub.bhavya31.hackclub.app/api/joke
Endpoint: /api/vote/<direction>/<int:joke_id>
Method: POST
Parameters:
direction: “up” for upvote, “down” for downvote.joke_id: The ID of the joke.Response:
{
"status": "success",
"id": 2,
"joke": "Another joke after voting"
}
Curl Command:
curl -X POST https://hahahub.bhavya31.hackclub.app/api/vote/up/26
Endpoint: /register
Method: POST
Request Body:
{
"username": "newuser",
"password": "password123"
}
Response:
{
"status": "success"
}
Endpoint: /login
Method: POST
Request Body:
{
"username": "newuser",
"password": "password123"
}
Response:
{
"status": "success"
}
Endpoint: /submit_joke
Method: POST
Request Body:
{
"joke": "Why did the chicken cross the road? To get to the other side!"
}
Response:
{
"status": "success"
}
Endpoint: /user
Method: GET
Response:
{
"jokes": [
"Joke 1",
"Joke 2"
]
}
Endpoint: /admin
Method: GET
Response:
{
"total_jokes": 100,
"top_jokes": [
{
"id": 1,
"joke": "Top voted joke"
}
]
}
Endpoint: /admin/edit/<int:joke_id>
Method: POST
Request Body:
{
"joke_text": "Updated joke content."
}
Response:
{
"status": "success"
}
Endpoint: /admin/delete/<int:joke_id>
Method: POST
Response:
{
"status": "success"
}
Endpoint: /change_password
Method: POST
Request Body:
{
"old_password": "currentpassword",
"new_password": "newpassword123",
"confirm_password": "newpassword123"
}
Response:
{
"status": "success"
}
Curl Command:
curl -X POST https://hahahub.bhavya31.hackclub.app/api/change_password \
-H "Content-Type: application/json" \
-d '{"old_password": "password123", "new_password": "newpassword456"}' \
-b cookies.txt
The application is deployed on PythonAnywhere. To deploy:
git checkout -b feature-name).git commit -m "Add new feature").git push origin feature-name).This project is licensed under the MIT License.
Enjoy sharing and laughing with HaHaHub! 🎉