host="127.0.0.1" user="root" password="" charset="utf8" database="service" port=3306
import MySQLdb
import sys
import config
class AService(object):
def getA(self,id):
conn = MySQLdb.connect(host=config.host,user=config.user,passwd=config.password,port=config.port,db=config.database,charset=config.charset)
result=[]
try:
cursor = conn.cursor();
cursor.execute("select id,code,title from test_a where id='%d'"%(id))
result = cursor.fetchone()
except Exception,e:
print "System error: ",e
result = "error"
finally:
cursor.close()
conn.close()
return result
import web
import aService
import sys
urls = ("/Service/A","hello")
app = web.application(urls,globals())
class hello:
def GET(self):
mservice = aService.AService()
result = mservice.getA(1)
json = ""
json +="{"
json +="'id':"+str(result[0])+","
json +="'code':'"+result[1]+"',"
json +="'title':'"+result[2]+"'"
json +="}"
return json;
if __name__=="__main__":
app.run()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有