From 07704199616228849c17302f21dd5a5a30dbea66 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 26 Jan 2018 14:12:33 +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/.add.html.un~ | Bin 0 -> 88954 bytes cgi-bin/.add.py.swp | Bin 0 -> 12288 bytes cgi-bin/.add.py.un~ | Bin 0 -> 28657 bytes cgi-bin/.img.py.swp | Bin 0 -> 12288 bytes cgi-bin/.img.py.un~ | Bin 0 -> 10922 bytes cgi-bin/.imgs.py.un~ | Bin 0 -> 117919 bytes cgi-bin/.issue.html.swp | Bin 0 -> 12288 bytes cgi-bin/.issue.html.un~ | Bin 14943 -> 26503 bytes cgi-bin/.issue.py.swp | Bin 0 -> 12288 bytes cgi-bin/.issue.py.un~ | Bin 85310 -> 90754 bytes cgi-bin/.page.html.swp | Bin 0 -> 12288 bytes cgi-bin/.page.html.un~ | Bin 7876 -> 8323 bytes cgi-bin/.page.py.swp | Bin 0 -> 12288 bytes cgi-bin/.path.py.swp | Bin 0 -> 12288 bytes cgi-bin/.path.py.un~ | Bin 0 -> 14735 bytes cgi-bin/__pycache__/path.cpython-36.pyc | Bin 0 -> 691 bytes cgi-bin/add.py | 22 ++++++++++++ cgi-bin/img.py | 52 +++++++++++++++++++++++++++++ cgi-bin/issue.html | 4 ++- cgi-bin/issue.py | 57 +++++++++++++++----------------- cgi-bin/log.txt | 0 cgi-bin/page.html | 2 +- cgi-bin/path.py | 12 +++++++ 23 files changed, 117 insertions(+), 32 deletions(-) create mode 100644 cgi-bin/.add.html.un~ create mode 100644 cgi-bin/.add.py.swp create mode 100644 cgi-bin/.add.py.un~ create mode 100644 cgi-bin/.img.py.swp create mode 100644 cgi-bin/.img.py.un~ create mode 100644 cgi-bin/.imgs.py.un~ create mode 100644 cgi-bin/.issue.html.swp create mode 100644 cgi-bin/.issue.py.swp create mode 100644 cgi-bin/.page.html.swp create mode 100644 cgi-bin/.page.py.swp create mode 100644 cgi-bin/.path.py.swp create mode 100644 cgi-bin/.path.py.un~ create mode 100644 cgi-bin/__pycache__/path.cpython-36.pyc create mode 100644 cgi-bin/img.py create mode 100644 cgi-bin/log.txt create mode 100644 cgi-bin/path.py (limited to 'cgi-bin') diff --git a/cgi-bin/.add.html.un~ b/cgi-bin/.add.html.un~ new file mode 100644 index 0000000..57c1714 Binary files /dev/null and b/cgi-bin/.add.html.un~ differ diff --git a/cgi-bin/.add.py.swp b/cgi-bin/.add.py.swp new file mode 100644 index 0000000..465de26 Binary files /dev/null and b/cgi-bin/.add.py.swp differ diff --git a/cgi-bin/.add.py.un~ b/cgi-bin/.add.py.un~ new file mode 100644 index 0000000..6547452 Binary files /dev/null and b/cgi-bin/.add.py.un~ differ diff --git a/cgi-bin/.img.py.swp b/cgi-bin/.img.py.swp new file mode 100644 index 0000000..82da003 Binary files /dev/null and b/cgi-bin/.img.py.swp differ diff --git a/cgi-bin/.img.py.un~ b/cgi-bin/.img.py.un~ new file mode 100644 index 0000000..d15ae3a Binary files /dev/null and b/cgi-bin/.img.py.un~ differ diff --git a/cgi-bin/.imgs.py.un~ b/cgi-bin/.imgs.py.un~ new file mode 100644 index 0000000..a86dd44 Binary files /dev/null and b/cgi-bin/.imgs.py.un~ differ diff --git a/cgi-bin/.issue.html.swp b/cgi-bin/.issue.html.swp new file mode 100644 index 0000000..8a34f7e Binary files /dev/null and b/cgi-bin/.issue.html.swp differ diff --git a/cgi-bin/.issue.html.un~ b/cgi-bin/.issue.html.un~ index 69fa826..1981975 100644 Binary files a/cgi-bin/.issue.html.un~ and b/cgi-bin/.issue.html.un~ differ diff --git a/cgi-bin/.issue.py.swp b/cgi-bin/.issue.py.swp new file mode 100644 index 0000000..2d89ae4 Binary files /dev/null and b/cgi-bin/.issue.py.swp differ diff --git a/cgi-bin/.issue.py.un~ b/cgi-bin/.issue.py.un~ index 665ee64..b3bc373 100644 Binary files a/cgi-bin/.issue.py.un~ and b/cgi-bin/.issue.py.un~ differ diff --git a/cgi-bin/.page.html.swp b/cgi-bin/.page.html.swp new file mode 100644 index 0000000..3632958 Binary files /dev/null and b/cgi-bin/.page.html.swp differ diff --git a/cgi-bin/.page.html.un~ b/cgi-bin/.page.html.un~ index e3e37d6..e28b9b7 100644 Binary files a/cgi-bin/.page.html.un~ and b/cgi-bin/.page.html.un~ differ diff --git a/cgi-bin/.page.py.swp b/cgi-bin/.page.py.swp new file mode 100644 index 0000000..4c9b355 Binary files /dev/null and b/cgi-bin/.page.py.swp differ diff --git a/cgi-bin/.path.py.swp b/cgi-bin/.path.py.swp new file mode 100644 index 0000000..298517e Binary files /dev/null and b/cgi-bin/.path.py.swp differ diff --git a/cgi-bin/.path.py.un~ b/cgi-bin/.path.py.un~ new file mode 100644 index 0000000..85f7f9f Binary files /dev/null and b/cgi-bin/.path.py.un~ differ diff --git a/cgi-bin/__pycache__/path.cpython-36.pyc b/cgi-bin/__pycache__/path.cpython-36.pyc new file mode 100644 index 0000000..c230e92 Binary files /dev/null and b/cgi-bin/__pycache__/path.cpython-36.pyc differ diff --git a/cgi-bin/add.py b/cgi-bin/add.py index e69de29..440b67f 100644 --- a/cgi-bin/add.py +++ b/cgi-bin/add.py @@ -0,0 +1,22 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +from issuedb import IssueDBFactory +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +db = IssueDBFactory.produce() +cursor = db.cursor() + +print("Content-type:text/html\n") +redirect = """ + + + + + +""".format(1) +print(redirect) + diff --git a/cgi-bin/img.py b/cgi-bin/img.py new file mode 100644 index 0000000..7a7751f --- /dev/null +++ b/cgi-bin/img.py @@ -0,0 +1,52 @@ +#!C:\Python364\python3.exe +# -*- coding: utf-8 -*- +import sys, codecs +import cgi, cgitb +import pymysql +import issuedb +from issuedb import IssueDBFactory +import os +import path +from path import Path +import time +sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) + +form = cgi.FieldStorage() + +fileobj = form['upload'] +callback = form.getvalue("CKEditorFuncNum") +fname, fext = os.path.splitext(fileobj.filename) + +def randname(): + return int(time.time()); + +rnd_name = '%s%s' % (randname(), fext) +filepath = Path.img(rnd_name) + +# 检查路径是否存在,不存在则创建 +dirname = os.path.dirname(filepath) +url = "" +error = "" +if not os.path.exists(dirname): + try: + os.makedirs(dirname) + except: + error = 'ERROR_CREATE_DIR' +elif not os.access(dirname, os.W_OK): + error = 'ERROR_DIR_NOT_WRITEABLE' +if not error: + open(filepath, 'wb').write(fileobj.file.read()) + #url = url_for('static', filename='%s/%s' % ('upload', rnd_name)) + url = Path.url("imgs/" + rnd_name) + +res = """ + + + +""" % (callback, url, error) + +print("Content-type:text/html\n") +print(res) + diff --git a/cgi-bin/issue.html b/cgi-bin/issue.html index 129a531..4315c9a 100644 --- a/cgi-bin/issue.html +++ b/cgi-bin/issue.html @@ -1,6 +1,6 @@ -issues tags +issue#{issueId} {issueTitle}
@@ -13,9 +13,11 @@
{tags}
+ 问题描述:
{issueDescription}
+ 解决方案:
{issueSolve}
diff --git a/cgi-bin/issue.py b/cgi-bin/issue.py index 83f6950..19a5414 100644 --- a/cgi-bin/issue.py +++ b/cgi-bin/issue.py @@ -17,36 +17,33 @@ issue_html_file = open("issue.html", 'r', encoding='utf8') issue_html = issue_html_file.read() tag_unit_html = tag_unit_html_file.read() - issue = "" -#try: -issueId = cgi.FieldStorage().getvalue("id") -cursor.execute("select * from issue where issueId={0}".format(issueId)) -issue_content = cursor.fetchall() -issue_content = issue_content[0] - -if issue_content != None: - taglist = "" - cursor.execute("SELECT * FROM tag WHERE tagId IN (SELECT tagId FROM relation WHERE issueId = {0})".format(issueId)) - tags_rows = cursor.fetchall() - for tag_row in tags_rows: - tag = tag_unit_html.format(\ - tagid = tag_row[0], \ - tag_name = tag_row[1],\ - tag_count = '' \ - ) - taglist += tag - issue = issue_html.format( \ - issueId = issue_content[0], \ - issueTitle = issue_content[1],\ - issueDescription = issue_content[2],\ - issueSolve = issue_content[3],\ - tags = taglist\ - ) -print(issue) -#except Exception, e: -#print("Error: unable to fetch data \n" + e.message) - - +try: + issueId = cgi.FieldStorage().getvalue("id") + cursor.execute("select * from issue where issueId={0}".format(issueId)) + issue_content = cursor.fetchall() + issue_content = issue_content[0] + + if issue_content != None: + taglist = "" + cursor.execute("SELECT * FROM tag WHERE tagId IN (SELECT tagId FROM relation WHERE issueId = {0})".format(issueId)) + tags_rows = cursor.fetchall() + for tag_row in tags_rows: + tag = tag_unit_html.format(\ + tagid = tag_row[0], \ + tag_name = tag_row[1],\ + tag_count = '' \ + ) + taglist += tag + issue = issue_html.format( \ + issueId = issue_content[0], \ + issueTitle = issue_content[1],\ + issueDescription = issue_content[2],\ + issueSolve = issue_content[3],\ + tags = taglist\ + ) + print(issue) +except: + print("Error: unable to fetch data \n" + e.message) diff --git a/cgi-bin/log.txt b/cgi-bin/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/cgi-bin/page.html b/cgi-bin/page.html index f5a5641..e2609f6 100644 --- a/cgi-bin/page.html +++ b/cgi-bin/page.html @@ -9,7 +9,7 @@ 标签 - 添加 + 添加
diff --git a/cgi-bin/path.py b/cgi-bin/path.py new file mode 100644 index 0000000..99152ce --- /dev/null +++ b/cgi-bin/path.py @@ -0,0 +1,12 @@ +dir = "C:/Users/chaifeixiang/Documents/python/issues/html/" + +class Path(object): + def full(p): + return dir + p + + def url(p): + return "/" + p + + def img(p): + return dir + 'imgs/' + p + -- cgit v1.1-26-g67d0