https://github.com/mithildabhi/cafe-api-web-app
Cafe API is a Flask app to add, view, search, update, and delete cafes using a web form or JSON API.
https://github.com/mithildabhi/cafe-api-web-app
flask html json python
Last synced: 2 months ago
JSON representation
Cafe API is a Flask app to add, view, search, update, and delete cafes using a web form or JSON API.
- Host: GitHub
- URL: https://github.com/mithildabhi/cafe-api-web-app
- Owner: mithildabhi
- Created: 2025-06-18T04:02:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-02T12:13:46.000Z (about 1 year ago)
- Last Synced: 2026-04-30T16:33:18.664Z (2 months ago)
- Topics: flask, html, json, python
- Language: HTML
- Homepage: https://restful-api-cafe.vercel.app/
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Cafe API Web App
================
📖 Project Description:
-----------------------
Cafe API is a simple Flask-based web app that lets users manage a list of cafes. You can view all cafes, search by location, add new cafes using a form, update coffee prices, and delete cafes using an API key. It's a great starter project for learning REST APIs, Flask, and database integration with SQLAlchemy.
-----------------------------
🛠️ Features:
-----------------------------
- Get a random cafe
- Get all cafes
- Search cafes by location
- Add new cafes via form or POST request
- Update the coffee price
- Delete a cafe using API key
-----------------------------
📁 Project Structure:
-----------------------------
```
- main.py --> Main Flask application
- templates/
├── index.html --> Homepage listing API endpoints
└── add_cafe.html --> Form to add new cafes
- cafes.db --> SQLite database (auto-created)
```
-----------------------------
📡 API Endpoints:
-----------------------------
```
GET /random -> Get a random cafe
GET /all -> Get all cafes
GET /search?loc= -> Search for cafes by location
GET /all/ -> Get a cafe by its ID
POST /add -> Add a new cafe (via form or POST data)
PATCH /update-price/?new_price= -> Update cafe price
DELETE /report-closed/?api-key=YOUR_API_KEY -> Delete a cafe (requires API key)
```
```
🔑 Default API key: mithildabhi_api_key
```
-----------------------------
🌐 Web Interface:
-----------------------------
- Home:
```
http://localhost:5000/
```
- Add Cafe:
```
http://localhost:5000/add
```
-----------------------------
▶️ Getting Started:
-----------------------------
1. Clone the repository
```
git clone https://github.com/yourusername/cafe-api.git
cd cafe-api
```
2. Install dependencies
```
pip install flask flask_sqlalchemy
```
3. Run the server
```
python main.py
```
4. Open your browser and go to http://localhost:5000/
-----------------------------
📌 Notes:
-----------------------------
- Database is created automatically if it doesn't exist.
- Can be tested using browser or tools like Postman/Insomnia.
- JSON responses follow consistent structure.
-----------------------------
👨💻 Author:
-----------------------------
Created by Mithil Dabhi