Python3 reads the mysql and sends out the interface. But every front-end call will report an error, how to solve this problem?

-sharpcoding=utf-8

from flask import Flask, request, jsonify, Blueprint
import json
import result.data as resultData
from MysqlHelper import MysqlHelper


import pymysql  -sharp pymysql

-sharp 
db = pymysql.connect(host="127.0.0.1", user="root", password="un", db="audit_test", port=3306)

-sharp cursor()
cursor = db.cursor()

api_database = Blueprint("database", __name__) -sharp 

-sharp 
@api_database.route("/api/database/common", methods=["POST", "GET"])
def select_database_json():
    sql = "select id,name,password from user"
    cursor.execute(sql)  -sharp sql
    -sharp for r in cursor.fetchall():
    -sharp     print(r)
    -sharp cursor.close()
    -sharp db.close()
    -sharp
    -sharp if results == ():
    -sharp     print("")
    -sharp elif results != ():
    -sharp     print("")
    -sharp else:
    -sharp     print("")
    -sharp     -sharp print(results)
    db.commit()
    cursor.close()
    db.close()
    helper = MysqlHelper()
    result_text = resultData.result_title_01
    -sharp print(result_text)
    response = jsonify(result_text)
    response.headers["Access-Control-Allow-Origin"] = "*"
    response.headers["Access-Control-Allow-Methods"] = "POST"
    response.headers["Access-Control-Allow-Headers"] = "x-requested-with,content-type"
    return response

Mar.31,2021
Menu