Skip to content

kpranat/Free-jokes-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

😂 Free Jokes API

⚡ Quick Start

# 1. Clone the repo
git clone https://github.com/yourusername/free-jokes-api.git
cd free-jokes-api

# 2. Install required Python packages
pip install -r requirements.txt

# 3. Run the Flask app
python app.py

# Access it at:
# http://localhost:5000/jokes

A simple and fun Flask-based API that lets users view and add jokes.
Deployed live at 👉 https://free-jokes-api.onrender.com


🔥 Features

  • ✅ GET & POST endpoints
  • ✅ JSON response format
  • ✅ Rate-limited: 10 requests per minute per IP
  • ✅ Easy deployment (Render-ready)
  • ✅ In-memory joke storage

📡 Live API Endpoints

GET /jokes

Returns all available jokes:

📌 Example:

curl https://free-jokes-api.onrender.com/jokes

📥 Sample Response:

{
  "jokes": [
    {
      "id": "J001",
      "setup": "Why do programmers prefer dark mode?",
      "punchline": "Because light attracts bugs!"
    },
    ...
  ]
}

POST /jokes

Add a new joke. Only punchline is required.

📌 Example:

curl -X POST https://free-jokes-api.onrender.com/jokes \
-H "Content-Type: application/json" \
-d '{"setup": "Why did the tomato blush?", "punchline": "Because it saw the salad dressing."}'

📥 Sample Response:

{
  "message": "New joke added"
}

🚫 Rate Limit

To prevent spam, each IP is limited to:

🔁 10 requests per minute

🛠️ Local Development

1. Clone this repo

git clone https://github.com/yourusername/free-jokes-api.git
cd free-jokes-api

2. Install dependencies

pip install -r requirements.txt

3. Run locally

python app.py

Go to: http://localhost:5000/jokes


🚀 Deployment on Render

  1. Push to GitHub
  2. Go to https://render.com
  3. Create New Web Service
  4. Fill:
Setting Value
Build Command pip install -r requirements.txt
Start Command python app.py
Runtime Python 3.x

✅ Done! Render gives you a public link.


📁 Project Structure

free-jokes-api/
├── app.py              # Flask API logic
├── requirements.txt    # Python packages
├── Procfile            # Render start command
└── runtime.txt         # Python version

📃 Dependencies

  • Flask
  • flask-limiter
  • gunicorn

Install with:

pip install -r requirements.txt

📄 License

MIT License — use it freely!


👋 Try It Live!

▶️ https://free-jokes-api.onrender.com

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages