%%python --bg
from flask import Flask, jsonify
from flask_cors import CORS
# initialize a flask application (app)
app = Flask(__name__)
CORS(app, supports_credentials=True, origins='*') # Allow all origins (*)
# ... your existing Flask
# add an api endpoint to flask app
@app.route('/api/data')
def get_data():
# start a list, to be used like a information database
InfoDb = []
# add a row to list, an Info record
InfoDb.append({
"FirstName": "Will",
"LastName": "Cheng",
"DOB": "Novemeber 27",
"Residence": "San Diego",
"Email": "funnykidland@gmail.com",
"Cats": ["siberian", "persian", "bengal", "maine-coon", "sphynx"]
})
# add a row to list, an Info record
InfoDb.append({
"FirstName": "Saaras",
"LastName": "Kodali",
"DOB": "October 1",
"Residence": "San Diego",
"Email": "kodalisaaras@gmail.com",
"Games": ["League of Legends", "Genshin Impact", "Valorant"]
})
InfoDb.append({
"FirstName": "Andrew",
"LastName": "Kim",
"DOB": "Novemeber 26",
"Residence": "San Diego",
"Email": "andrew.kim328@gmail.com",
"Music": ["Ghibli", "Nukes", "Nirvana"]
})
return jsonify(InfoDb)
# add an HTML endpoint to flask app
@app.route('/')
def say_hello():
html_content = """
<html>
<head>
<title>Team Influencer Innovator's Blog</title>
</head>
<body>
<h2>Hi everyone! We are Team Influence and Innovators, our teams consist of Will Cheng, Saaras Kodali, Daniel Lee, Andrew Kim, and Ryan Liao!</h2>
</body>
</html>
"""
return html_content
if __name__ == '__main__':
# starts flask server on default port, http://127.0.0.1:5001
app.run(port=5001)