Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
39d7d08
先去吃饭=w=
NKUCodingCat Feb 14, 2015
7b6f8b0
-w-
NKUCodingCat Feb 14, 2015
211d604
0024完成
NKUCodingCat Feb 14, 2015
6c11924
0024-SQL-update
NKUCodingCat Feb 14, 2015
d75aef2
0000 commit
starlightme Feb 14, 2015
33d5a04
compelte 0001
starlightme Feb 14, 2015
4a86e5d
complete 0002
starlightme Feb 15, 2015
fe26360
complete 0003
starlightme Feb 16, 2015
787294c
complete 0004
starlightme Feb 16, 2015
e9c4c50
fix 0004.py and add a README file
starlightme Feb 17, 2015
398e32e
complete 0005
starlightme Feb 18, 2015
f54e789
complete 0005
starlightme Feb 18, 2015
213432d
complete 0005
starlightme Feb 18, 2015
1f76db8
deleted other files
starlightme Feb 18, 2015
ad29945
fix
starlightme Feb 18, 2015
2dec509
complete 0006
starlightme Feb 18, 2015
5c9bdff
fix 0006 and commit 0007
starlightme Feb 19, 2015
24dda92
complete 0007
starlightme Feb 20, 2015
24bc113
你懂的
starlightme Feb 20, 2015
544e063
add respond
starlightme Feb 21, 2015
7611cec
complete 0009
starlightme Feb 23, 2015
e5c250c
complete 0008
starlightme Feb 24, 2015
b0055fe
complete 0000-0010
starlightme Feb 24, 2015
32e6b05
Delete test.py
starlightme Feb 24, 2015
e807409
complete 0011
starlightme Feb 25, 2015
ac84b1c
complete 0012
starlightme Feb 25, 2015
0a75886
remove some files
starlightme Feb 26, 2015
187d7f1
complete 0014
starlightme Feb 26, 2015
380c769
complete 0015
starlightme Feb 26, 2015
a891111
complete 0016
starlightme Feb 27, 2015
9e4b9b2
Merge pull request #62 from starlightme/master
horx Feb 28, 2015
9ccaac3
Merge pull request #61 from NKUCodingCat/master
horx Feb 28, 2015
a9371a2
Revert "Complete 0000-0003"
horx Feb 28, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions NKUCodingCat/0024/0024.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# SQL-Front 5.1 (Build 4.16)

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE */;
/*!40101 SET SQL_MODE='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES */;
/*!40103 SET SQL_NOTES='ON' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;


# Host: localhost Database: 0024
# ------------------------------------------------------
# Server version 5.5.38

DROP DATABASE IF EXISTS `0024`;
CREATE DATABASE `0024` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `0024`;

#
# Source for table code
#

DROP TABLE IF EXISTS `code`;
CREATE TABLE `code` (
`id` int(20) NOT NULL DEFAULT '0',
`to` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#
# Dumping data for table code
#

LOCK TABLES `code` WRITE;
/*!40000 ALTER TABLE `code` DISABLE KEYS */;
INSERT INTO `code` VALUES (13,'haiohpd');
INSERT INTO `code` VALUES (14,'daduwwg');
INSERT INTO `code` VALUES (9,'7');
INSERT INTO `code` VALUES (11,'9');
/*!40000 ALTER TABLE `code` ENABLE KEYS */;
UNLOCK TABLES;

#
# Source for table max
#

DROP TABLE IF EXISTS `max`;
CREATE TABLE `max` (
`pro` varchar(255) DEFAULT NULL,
`max` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#
# Dumping data for table max
#

LOCK TABLES `max` WRITE;
/*!40000 ALTER TABLE `max` DISABLE KEYS */;
INSERT INTO `max` VALUES ('max',15);
/*!40000 ALTER TABLE `max` ENABLE KEYS */;
UNLOCK TABLES;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
53 changes: 53 additions & 0 deletions NKUCodingCat/0024/SQLIO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#coding=utf-8
import time, os, json, MySQLdb, HTMLParser, cgi
def SQL_init():
db = MySQLdb.connect("127.0.0.1","root","root","0024" )
return db.cursor()
def SQL_max(new=None):
cursor = SQL_init()
if new != None:
sql="""UPDATE `max` SET `max`=%d WHERE `pro`='max'"""%new
cursor.execute(sql)
return True
else:
sql="""SELECT * FROM `max` WHERE `pro`='max'"""
cursor.execute(sql)
max = cursor.fetchall()[0][1]
SQL_max(max+1)
return max
def SQL_in(task):
max = SQL_max()
cursor = SQL_init()
sql = """INSERT INTO `code` SET `id`=%d,`to`='%s';"""%(max, task)
cursor.execute(sql)
return True
def SQL_out():
cursor = SQL_init()
sql = """SELECT * FROM `code`"""
cursor.execute(sql)
return cursor.fetchall()
def SQL_del(id):
cursor = SQL_init()
sql = """DELETE FROM `code` WHERE `id`=%d"""%id
cursor.execute(sql)
return json.dumps(cursor.fetchall())
#-----------
Temp = """
<tr>
<td class="task">%s</td>
<td class="manage">
<div align="center">
<input type="submit" name="id-%d" id="delete" value="删除" />
</div></td>
</tr>
"""


def PageMake():
Data = SQL_out()
All = ""
Data = sorted(Data,key=lambda a:a[0] )
for i in Data:
#print i
All+=Temp%(str(i[1]),int(i[0]))
return All
71 changes: 71 additions & 0 deletions NKUCodingCat/0024/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#coding=utf-8
const = """
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<link type="text/css" rel="stylesheet" href="./static/css.css" />
</head>

<body>
<h1>TodoList应用演示</h1>

<form action="" method="post">

<table>
<tr>
<td class="task_h"><div align="center">任务</div></td>
<td class="manage_h"><div align="center">管理</div></td>
</tr>

{0}
</table>
<br>
<textarea name="newtask" id="newtask" maxlength="500"></textarea>
<input type="submit" name="new" id="submit" value="创建新任务" />
</form>


</body>
</html>
"""


from bottle import static_file,route, run, post, request, redirect, error
import os, urllib,re,json,time
Root = os.path.split(os.path.realpath(__file__))[0]+"/static/"
import SQLIO

@route('/todo')
def index():
return const.format(SQLIO.PageMake(),)
@post('/todo')
def Accept():
Req = request.body.read()
L = re.split("&",Req)
M = {}
for i in L:
A = re.split("=",i)
M[A[0]] = urllib.unquote(A[1])
for j in M.keys():
if re.findall("id-",j):
SQLIO.SQL_del(int(j[3:]))
redirect('/todo', 302)
try:
type = M["new"]
newtask = M["newtask"]
except:
redirect('/error', 404)
if newtask != "":
SQLIO.SQL_in(newtask)
redirect('/todo', 302)
else:
return "=.=所以你想添加什么任务呀"

@route('/error')
def err():
return "虽然不知道你在干什么但是触发了服务器错误呢"
@route('/static/<filename>')
def server_static(filename):
return static_file(filename, root=Root)
run(host='localhost',port=8080)
1 change: 1 addition & 0 deletions NKUCodingCat/0024/static/css.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.