summaryrefslogtreecommitdiff
path: root/cgi-bin/page.py
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-01-29 15:37:45 +0800
committerchai <chaifix@163.com>2018-01-29 15:37:45 +0800
commit5d77906331243354710712ddf45b8bcb2152dacc (patch)
tree28319897afc0d22fde2e42e834885f16834a6db6 /cgi-bin/page.py
parent07704199616228849c17302f21dd5a5a30dbea66 (diff)
*修改
Diffstat (limited to 'cgi-bin/page.py')
-rw-r--r--cgi-bin/page.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/cgi-bin/page.py b/cgi-bin/page.py
index 8bdbc0a..ac5e89b 100644
--- a/cgi-bin/page.py
+++ b/cgi-bin/page.py
@@ -10,7 +10,6 @@ from config import Config
sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
-print("Content-type:text/html\n")
db = IssueDBFactory.produce()
cursor = db.cursor()
@@ -28,8 +27,20 @@ tag_unit_html_file.close()
issues_list = ""
issues_count = Config.get("config", "issues_count")
+issues_count = int(issues_count)
+#处理页号
+form = cgi.FieldStorage()
+
+pagen = form.getvalue('p')
+if pagen == None:
+ pagen = 0
+pageprev = int(pagen) - 1
+if pageprev < 0:
+ pageprev = 0
+pagenext = int(pagen) + 1
+
try:
- cursor.execute("select * from issue limit 0, 10")
+ cursor.execute("select * from issue ORDER BY issueId DESC LIMIT {0}, {1}".format(pagen*issues_count, issues_count))
issues_rows = cursor.fetchall()
odd = True
for row in issues_rows:
@@ -56,16 +67,6 @@ try:
except:
print("Error: unable to fetch data")
-#处理页号
-form = cgi.FieldStorage()
-pagen = form.getvalue('p')
-if pagen == None:
- pagen = 0
-pageprev = pagen - 1
-if pageprev < 0:
- pageprev = 0
-pagenext = pagen + 1
-
page = page_html.format(\
issues = issues_list, \
page_prev = pageprev, \
@@ -73,6 +74,7 @@ page = page_html.format(\
)
# HTTP header
+print("Content-type:text/html\n")
print(page)
db.commit()