Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created April 27, 2022 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/7e9b57625836bd39ed9051221caa37a1 to your computer and use it in GitHub Desktop.
Save richardgrantserverless/7e9b57625836bd39ed9051221caa37a1 to your computer and use it in GitHub Desktop.
from collections import namedtuple
from random import choice
from flask import Flask, jsonify
Quote = namedtuple("Quote", ("text", "author"))
quotes = [
Quote("Talk is cheap. Show me the code.", "Linus Torvalds"),
Quote("Programs must be written for people to read, and only incidentally for machines to execute.", "Harold Abelson"),
Quote("Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live",
"John Woods"),
Quote("Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime.", "Muhammad Waseem"),
Quote("Progress is possible only if we train ourselves to think about programs without thinking of them as pieces of executable code. ",
"Edsger W. Dijkstra")
]
app = Flask(__name__)
@app.route("/quote", methods=["GET"])
def get_random_quote():
return jsonify(choice(quotes)._asdict())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment