代码拉取完成,页面将自动刷新
# encoding: utf-8
# !/usr/bin/env python
import web
import MySQLdb
from DBHelper import DBHelper
render = web.template.render('template/')
urls = (
'/', 'index',
'/add', 'add'
)
app = web.application(urls, globals())
db = web.database(dbn='mysql',user='root',pw='lovemin8',db='test')
class index:
def GET(self):
todo = db.select('todo')
return render.index(todo)
class add:
def POST(self):
i = web.input()
# n = db.insert('todo', title=i.title)
dbHelper = DBHelper()
print i.name
# print i.content
print i.markdown
# dbHelper.execute("SELECT count(*) FROM posts")
dbHelper.execute("INSERT INTO posts(id, uuid, title, markdown, html, img, author_id) values(123, '123-123', %s, %s,"
"%s,'none', '321'" % (i.name, i.markdown, i.content))
print dbHelper.readOne("SELECT count(*) FROM posts")
# INSERT INTO posts(id, uuid, title, markdown, html, img, author_id) values(123, '123-123', i.name, i.markdown, i.content,
# Open Database Connection
# db = MySQLdb.connect("localhost", "root", "lovemin8", "ghost")
# cursor = db.cursor()
# cursor.execute("SELECT * FROM posts")
# data = cursor.fetchone()
# db.close()
raise web.seeother('/')
if __name__ == '__main__':
app.run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。