1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!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")
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
pageprev = int(pagen) - 1
if pageprev < 0:
pageprev = 0
pagenext = int(pagen) + 1
# class PageBuilder(object):
# def build(pagen):
print("Content-type:text/html\n")
db = Connect.produce()
cursor = db.cursor()
query_allwhisper = "select * from whisper"
cursor.execute(query_allwhisper)
_whispers=""
whispersdata = cursor.fetchall()
odd = True
for whisper in whispersdata:
_whispers += Whisper.build(whisper[0], whisper[1], odd)
odd = not odd
page = page_templ.format(\
url = _url,
static = _static,
whispers = _whispers,
page_prev = pageprev,
page_next = pagenext
)
print(page)
db.commit()
cursor.close()
db.close()
|