A Flask-based web application that generates random jokes using the JokeAPI. Users can customize their joke experience by selecting categories, languages, and content filters.
- Multiple joke categories (Programming, Misc, Dark, Pun, Spooky, Christmas)
- Support for multiple languages (Czech, German, English, Spanish, French, Portuguese)
- Content filtering options (NSFW, Religious, Political, Racist, Sexist, Explicit)
- Responsive web interface using Bootstrap
- Error handling and user feedback
- Debug information display
- Python 3.x
- Flask 3.1.0
- Bootstrap 5.3.0
- JokeAPI v2
- Requests library
- Gunicorn (for production deployment)
- Clone the repository:
git clone https://github.com/yourusername/random-joke-web-app.git
cd random-joke-web-app- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`- Install the required dependencies:
pip install -r requirements.txt- Start the development server:
python app.py- Open your web browser and navigate to:
http://localhost:5001
- Use the web interface to:
- Select joke categories (Any or Custom)
- Choose your preferred language
- Set content filters
- Click "Show me the joke" to generate a random joke
random-joke-web-app/
├── app.py # Main Flask application
├── requirements.txt # Project dependencies
└── templates/
├── base.html # Base template with common elements
├── index.html # Home page with joke configuration
└── joke.html # Joke display page
The application integrates with JokeAPI v2 (https://v2.jokeapi.dev/) to fetch jokes. The API endpoint is constructed based on user selections:
- Base URL:
https://v2.jokeapi.dev/joke - Parameters:
- Category: Single or multiple categories
- Language: User-selected language code
- Blacklist flags: User-selected content filters
The application includes comprehensive error handling for:
- API connection issues
- Invalid category selections
- Missing jokes for selected parameters
- General API errors
flask run --debug --port=5001- Create a new branch for your feature
- Implement the feature
- Test thoroughly
- Submit a pull request
The application is configured to run with Gunicorn in production:
gunicorn app:app- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by @Zuiliam
- Built with assistance from ChatGPT (Part 1 without Bootstrap | (Part 2 adding Bootstrap)
- Deployed by Augusto
- Uses JokeAPI for joke content
- Bootstrap for frontend styling