From c1803a7603135e2c148d89d5e05596f5d251842a Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 31 Jan 2018 18:27:58 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cgi-bin/.page.py.swp | Bin 12288 -> 0 bytes cgi-bin/.whisper.py.un~ | Bin 0 -> 13233 bytes cgi-bin/add.py | 0 cgi-bin/config.ini | 19 +++++++++++++++++++ cgi-bin/config.py | 13 +++++++++++++ cgi-bin/connect.py | 14 ++++++++++++++ cgi-bin/edit.py | 0 cgi-bin/page.py | 3 +++ cgi-bin/path.py | 21 +++++++++++++++++++++ cgi-bin/template/.whisper.html.un~ | Bin 0 -> 523 bytes cgi-bin/template/add.html | 0 cgi-bin/template/edit.html | 0 cgi-bin/template/page.html | 3 +++ cgi-bin/template/style.css | 0 cgi-bin/template/whisper.html | 4 ++++ cgi-bin/whisper.py | 20 ++++++++++++++++++++ 16 files changed, 97 insertions(+) delete mode 100644 cgi-bin/.page.py.swp create mode 100644 cgi-bin/.whisper.py.un~ create mode 100644 cgi-bin/add.py create mode 100644 cgi-bin/config.ini create mode 100644 cgi-bin/config.py create mode 100644 cgi-bin/connect.py create mode 100644 cgi-bin/edit.py create mode 100644 cgi-bin/path.py create mode 100644 cgi-bin/template/.whisper.html.un~ create mode 100644 cgi-bin/template/add.html create mode 100644 cgi-bin/template/edit.html create mode 100644 cgi-bin/template/style.css create mode 100644 cgi-bin/template/whisper.html create mode 100644 cgi-bin/whisper.py (limited to 'cgi-bin') diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp deleted file mode 100644 index c0f93be..0000000 Binary files a/cgi-bin/.page.py.swp and /dev/null differ diff --git a/cgi-bin/.whisper.py.un~ b/cgi-bin/.whisper.py.un~ new file mode 100644 index 0000000..4f409c2 Binary files /dev/null and b/cgi-bin/.whisper.py.un~ differ diff --git a/cgi-bin/add.py b/cgi-bin/add.py new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/config.ini b/cgi-bin/config.ini new file mode 100644 index 0000000..b246c3b --- /dev/null +++ b/cgi-bin/config.ini @@ -0,0 +1,19 @@ +[route] +#需要配置apache +#根路由 +url="/chai/whisper/" +#静态根目录 +static_root="/html/" +imgs_dir="/html/imgs/" +#html模板目录 +templ_dir="template/" +[database] +user="root" +passwd="root" +host="localhost" +port=3306 +database="whisper" +[config] +#每页显示whisper条数 +whisper_count=10 + diff --git a/cgi-bin/config.py b/cgi-bin/config.py new file mode 100644 index 0000000..f9ee2f6 --- /dev/null +++ b/cgi-bin/config.py @@ -0,0 +1,13 @@ +# parse config.ini +# -*- coding: utf-8 -*- +import configparser, codecs, sys + +conf = configparser.ConfigParser() +conf.read("config.ini") + +class Config(object): + @classmethod + def get(cls, section, option): + return conf.get(section, option) + + diff --git a/cgi-bin/connect.py b/cgi-bin/connect.py new file mode 100644 index 0000000..c027978 --- /dev/null +++ b/cgi-bin/connect.py @@ -0,0 +1,14 @@ +import pymysql +import config +from config import Config + +host = Config.get("database", "host") +port = Config.get("database", "port") +user = Config.get("database", "user") +passwd = Config.get("database", "passwd") +db = Config.get("database", "database") + +class Connect(object): + def produce(): + return pymysql.connect(host, user, passwd, db) + diff --git a/cgi-bin/edit.py b/cgi-bin/edit.py new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/page.py b/cgi-bin/page.py index e69de29..b28b04f 100644 --- a/cgi-bin/page.py +++ b/cgi-bin/page.py @@ -0,0 +1,3 @@ + + + diff --git a/cgi-bin/path.py b/cgi-bin/path.py new file mode 100644 index 0000000..ac1ed5a --- /dev/null +++ b/cgi-bin/path.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +import config +from config import Config + +root = Config.get("route", "url") +imgsDir = Config.get("route", "imgs_dir") +templDir = Config.get("route", "templ_dir") + +class Path(object): + # 拼接url + def url(path): + return root + path + + # 保存的图片路径 + def img(imgFile): + return root + imgsDir + imgFile + + # html模板路径 + def template(templ): + return templDir + templ + diff --git a/cgi-bin/template/.whisper.html.un~ b/cgi-bin/template/.whisper.html.un~ new file mode 100644 index 0000000..70eaf48 Binary files /dev/null and b/cgi-bin/template/.whisper.html.un~ differ diff --git a/cgi-bin/template/add.html b/cgi-bin/template/add.html new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/template/edit.html b/cgi-bin/template/edit.html new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/template/page.html b/cgi-bin/template/page.html index e69de29..b28b04f 100644 --- a/cgi-bin/template/page.html +++ b/cgi-bin/template/page.html @@ -0,0 +1,3 @@ + + + diff --git a/cgi-bin/template/style.css b/cgi-bin/template/style.css new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/template/whisper.html b/cgi-bin/template/whisper.html new file mode 100644 index 0000000..fd40910 --- /dev/null +++ b/cgi-bin/template/whisper.html @@ -0,0 +1,4 @@ + + + + diff --git a/cgi-bin/whisper.py b/cgi-bin/whisper.py new file mode 100644 index 0000000..0372b03 --- /dev/null +++ b/cgi-bin/whisper.py @@ -0,0 +1,20 @@ +import path +from path import Path +import connect +from connect import Connect + +class Whisper(object): + def build(whisperId): + conn = Connect.produce() + cursor = conn.cursor() + + whisper_file = open(Path.template("whisper.html"), 'r', encoding="utf8") + whisper_templ = whisper_file.read() + whisper_file.close() + + + + conn.close() + + + -- cgit v1.1-26-g67d0