Fetch the repository succeeded.
This action will force synchronization from mktime/python-learn, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#-*- 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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。