Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
from flask import json, jsonify
from app import app
from app import db
from flask import jsonify, request
from app import app, db
from app.models import Menu

# Health check
@app.route('/')
def home():
return jsonify({ "status": "ok" })
return jsonify({"status": "ok"}), 200

@app.route('/menu')
def menu():
today = Menu.query.first()

# Get today's menu
@app.route('/menu', methods=['GET'])
def get_menu():
today = Menu.query.first() # Adjust filter logic if needed
if today:
body = { "today_special": today.name }
status = 200
return jsonify({
"menu": today.serialize(), # Make sure Menu model has serialize() method
"status": "available"
}), 200
else:
body = { "error": "Sorry, the service is not available today." }
status = 404
return jsonify(body), status
return jsonify({"error": "Sorry, the service is not available today."}), 404


# Add or update menu
@app.route('/menu', methods=['POST'])
def add_menu():
data = request.json
if not data or "name" not in data or "price" not in data:
return jsonify({"error": "Invalid data. 'name' and 'price' are required."}), 400

Check notice on line 30 in app/routes.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/routes.py#L30

Trailing whitespace
try:
menu_item = Menu(name=data["name"], price=data["price"])
db.session.add(menu_item)
db.session.commit()
return jsonify({"message": "Menu item added successfully"}), 201
except Exception as e:
db.session.rollback()
return jsonify({"error": str(e)}), 500
1 change: 1 addition & 0 deletions new-repo1
Submodule new-repo1 added at 35115e