1 Star 0 Fork 0

liqiang/NewBlog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.py 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
liqiang 提交于 2015-04-30 23:31 . add files
# 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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/liuliqiang/NewBlog.git
git@gitee.com:liuliqiang/NewBlog.git
liuliqiang
NewBlog
NewBlog
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385