Ai
1 Star 0 Fork 262

村西康师傅/project_20595785

forked from mktime/python-learn 
Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
index.py 1.28 KB
Copy Edit Raw Blame History
mktime authored 2014-04-15 00:08 +08:00 . thread fetch
#-*- coding=utf-8 -*-
import web
urls = (
'/', 'Index',
'/(.*)', 'Info',
);
render = web.template.render('templates', cache=False)
db = web.database(dbn='sqlite', db='../qiubai.db')
config = web.storage(
email='withfaker@gmail.com',
site_name = '测试',
site_desc = '',
static = '/static',
)
web.template.Template.globals['config'] = config
def query_next_pic(created):
sql = "select created, img_src, content from t_qiushi where created < '{0}' order by created desc limit 1".format(created)
res = db.query(sql)
if not res:
return None
return res
class Index:
def GET(self):
print type(web.ctx)
print web.ctx['environ']['REMOTE_ADDR']
return render.index()
class Info:
def GET(self, created):
info = query_next_pic(created)
if not info:
return '{"status":99}'
ret = '{"status":200, "data":['
s = ""
for i in info:
ret = ret + '{"created":' + '"' + i['created'] + '",' + '"img_src":"' + i['img_src'] + '", "content":"' + i['content'] + '"},'
ret = ret + ']}'
pos = ret.rfind(',')
ret = ret[0:pos] + ret[pos+1:]
return ret
if __name__ == '__main__':
app = web.application(urls, globals())
app.run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/huteddy/python-learn.git
git@gitee.com:huteddy/python-learn.git
huteddy
python-learn
project_20595785
master

Search