diff options
author | chai <chaifix@163.com> | 2018-07-13 21:53:49 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-13 21:53:49 +0800 |
commit | 7ca80e57f06922e464626c7a6a1d7965e716b53f (patch) | |
tree | bda9271234720424b7dfc5c2d25b9df4ba3d01df /cgi-bin/page.py | |
parent | 181b206863d3765fe5343ceea8e1e00e52ffba9e (diff) |
Diffstat (limited to 'cgi-bin/page.py')
-rw-r--r-- | cgi-bin/page.py | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/cgi-bin/page.py b/cgi-bin/page.py deleted file mode 100644 index b776d8e..0000000 --- a/cgi-bin/page.py +++ /dev/null @@ -1,75 +0,0 @@ -#!D:/Programs/Python3/python.exe -# -*- coding: utf-8 -*- -import cgi, cgitb -import pymysql -import sys, codecs -import configparser, codecs -import connect -from connect import Connect -import whisper -from whisper import Whisper -import config -from config import Config -import path -from path import Path - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) - -_url = Config.get("route", "url") -_static = Config.get("route", "static") -_whiperperpage = int(Config.get("config", "whisper_count")) - -page_file = open(Path.template("page.html"), 'r', encoding="utf8") -page_templ = page_file.read() -page_file.close() - -pagen = cgi.FieldStorage().getvalue('p') -if pagen == None: - pagen = 0 -else: - pagen = int(pagen) -pageprev = pagen - 1 -if pageprev < 0: - pageprev = 0 -pagenext = pagen + 1 - -# class PageBuilder(object): -# def build(pagen): -print("Content-type:text/html\n") - -db = Connect.produce() -cursor = db.cursor() - -query_count = "select COUNT(*) from whisper" -cursor.execute(query_count) -whispercount = cursor.fetchone() -whispercount = whispercount[0] - -query_allwhisper = "select * from whisper ORDER BY id DESC LIMIT {0}, {1}".format(pagen * _whiperperpage, _whiperperpage) -cursor.execute(query_allwhisper) - -_whispers = "" -whispersdata = cursor.fetchall() -odd = True -count = 0 -for whisper in whispersdata: - count = count + 1 - _whispers += Whisper.build(whisper[0], whisper[1], whisper[2], odd, _url) - odd = not odd - -if pagen * _whiperperpage + count >= whispercount: - pagenext = pagen - -page = page_templ.format(\ - url = _url, - static = _static, - whispers = _whispers, - page_prev = pageprev, - page_next = pagenext -) - -print(page) - -db.commit() -cursor.close() -db.close() |