Skip to content

Instantly share code, notes, and snippets.

@noahjames404
Created March 26, 2025 09:14
Show Gist options
  • Select an option

  • Save noahjames404/e5b95c1a9a0f99a23a9f9732bda55fad to your computer and use it in GitHub Desktop.

Select an option

Save noahjames404/e5b95c1a9a0f99a23a9f9732bda55fad to your computer and use it in GitHub Desktop.
api demo in flask environment
from flask import Flask, request
app = Flask(__name__)
@app.route("/")
def hello_world():
searchword = request.args.get('key', '')
return {
"searchword": searchword,
"username": "ivan",
"first_name": "ivan",
"last_name": "santos",
"hobbies": "badminton"
}
@app.route("/sum")
def sum():
a = request.args.get('a', 0)
b= request.args.get('b',0)
return {
"sum": float(a) + float(b)
}
@app.route("/authenticate", methods=["POST"])
def authenticate():
username = request.form['username']
password = request.form['password']
res = False
if(username == "ivan" and password == "ivan"):
res = True
return {
"username": username,
"password": password,
"authenticated": res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment