无法查看屏幕上的输出 [英] unable to view output on screen

查看:138
本文介绍了无法查看屏幕上的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

my code is as follows :

from flask import Flask
from flaskext.mysql import MySQL

mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'OMTSL_QBO'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)

@app.route("/")
def hello():
    return "Welcome to Python Flask App!"

@app.route("/Authenticate")
def Authenticate():
    cursor = mysql.connect().cursor()
    cursor.execute("SELECT count(*) from REPORT_SUITE")
    data = cursor.fetchone()
    print data    
    return data

if __name__ == "__main__":
    app.run(debug = True)

我无法在屏幕上查看计数。我得到的错误是TypeError:'长'对象不可调用。请帮助。

i am unable to view the count on screen . The error i am getting is TypeError: 'long' object is not callable.. Please help.

推荐答案

您需要返回字符串或从瓶子视图函数的响应,因为你正在返回 long type flask正在抱怨。详细了解回复此处

You need to return string or response from flask view function and since you are returning long type flask is complaining. Learn more about responses here.

在你的情况下,只需要执行 return str(data)

In your case it'll be enough to do return str(data).

这篇关于无法查看屏幕上的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆