在XAMPP上运行python脚本时出现服务器错误

时间:2015-09-22 10:52:14

标签: python mysql xampp bottle

我编写了一个python脚本来从数据库中名为users的表中获取所有数据。我正在使用xampp服务器和mysql。当我尝试运行脚本时,它给了我一个错误:

Server error!

The server encountered an internal error and was unable to complete your request.

Error message: 
End of script output before headers: test3.py

If you think this is a server error, please contact the webmaster.

Error 500

localhost
Apache/2.4.12 (Unix) OpenSSL/1.0.1p PHP/5.6.11 mod_perl/2.0.8-dev Perl/v5.16.3 

这是我用瓶子框架编写的python脚本:

#!/Python27/python

from bottle import route, run
import json
import MySQLdb as db

@route('/users', method = 'GET')
def getUser():
    c = db.connect('localhost','root','','temp')
    cur = c.cursor()
    sql1 = 'SELECT * FROM Users;'
    cur.execute(sql1)
    result = cur.fetchall();
    c.commit()
    c.close()

    j= json.dumps(result)
    return j

0 个答案:

没有答案