How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • Go back-and-forth until satisfied
    Rate the answer you receive.
Ask LogicPro Your Own Question
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 35251
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
Type Your Programming Question Here...
LogicPro is online now

Could you please add detailed comments to each line of code,

Customer Question

Could you please add detailed comments to each line of code, replace any existing comments. thanks.from flask import Flask, render_template, request, jsonify
# this is library used for database
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS# initilizing python flask app
app = Flask(__name__)
# this is way to make connection with database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.sqlite'
# initilzing database for the current app
db = SQLAlchemy(app)# now creating Model where we will save qoute dataclass qoutes(db.Model):
id = db.Column(db.Integer, primary_key=True)
qoute_id = db.Column(db.String(200))
date = db.Column(db.String(200))
name = db.Column(db.String(200))
notes = db.Column(db.String(200))# this is index view
def index():
return render_template("index.html")# getting all the qoutes data as a table
def list():
qoutes_data = qoutes.query.all()
data = []for values in qoutes_data:
data.append({"quotes_id": values.qoute_id, "quotes_date":, "quotes_name":,
"quotes_notes": values.notes, "qoutes_id": values.qoute_id})print(data)
return jsonify(data)# show data for single quotes
@app.route("/quote/show/", methods=['PATCH'])
def show(id):
single_quote = qoutes.query.filter_by(qoute_id=id).first()
findExist = {
"quotes_id": single_quote.qoute_id,
"quotes_notes": single_quote.notes
}print(findExist)return {'success': 'true', 'msg': 'quote data show successfully', 'data': findExist}# delete quotes
@app.route("/quote/delete/", methods=['DELETE'])
def delete(id):
# first let get data from database with sepecified id
to_be_deleted = qoutes.query.filter_by(qoute_id=id).first()# now deleting the above record
db.session.commit()return {'success': 'true', 'msg': 'quote removed successfully'}# update values
@app.route("/quote/update/", methods=['PATCH'])
def update(id):
# getting data from database with given id
quotes_data = qoutes.query.filter_by(qoute_id=id).first()# getting updated values from the request body
updated_values = request.get_json()# updating values for the specified id
quotes_data.quote_id = updated_values['quotes_id'] = updated_values['quotes_date'] = updated_values['quotes_name']
quotes_data.notes = updated_values['quotes_notes']# now commit all changes we have made
# commit will add all the changes to database
db.session.commit()return {'success': 'true', 'msg': 'quote data updated successfully'}# add quotes data
@app.route("/quote/add", methods=["POST"])
def add_qoute():
datas = request.get_json()
print(datas)# check if qoutes field are mssing
if datas['quotes_id'] == "" or datas['quotes_date'] == "" or datas['quotes_name'] == "" or datas[
'quotes_notes'] == "":
return {'error': 'true', 'msg': 'qoutes data missing'}# checking if quotes id already exists
# if quote id exists return
prev_data = qoutes.query.filter_by(qoute_id=datas['quotes_id']).first()
if prev_data:
return {"error": 'true', 'msg': 'quotes id already exists'}
pass# now we are saving qoutes data to database
qoutes_data = qoutes(
)# submitting data to database
db.session.commit()return {'success': 'true', 'msg': 'quote data added successfully', 'data': datas}if __name__ == "__main__":
Submitted: 16 days ago.
Category: Programming
Expert:  LogicPro replied 16 days ago.


Customer: replied 16 days ago.
Expert:  LogicPro replied 16 days ago.

please paste your code in a text document and upload here as formatting is not clear here

Customer: replied 15 days ago.
File attached (GL7P4G5)
Expert:  LogicPro replied 15 days ago.

I will check it and reply you

Customer: replied 15 days ago.
Expert:  LogicPro replied 15 days ago.

Here it is:!AlB0kaoYWazHlWZx5AvGzofeLhhk?e=kgvdzz


To get help with next question/requirement/issue, follow these steps:

Select five stars and add me to favorites

Then click on "Ask your favorite Expert new question" to send me next question and get instant help.

You can also go to my profile page:

under my image, tag me using "@For LogicPro only" and click on "Ask your Question" to start chatting and get instant help

Take care and stay safe