From 7ca80e57f06922e464626c7a6a1d7965e716b53f Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 13 Jul 2018 21:53:49 +0800 Subject: update --- cgi-bin/add.py | 63 ---------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 cgi-bin/add.py (limited to 'cgi-bin/add.py') diff --git a/cgi-bin/add.py b/cgi-bin/add.py deleted file mode 100644 index e3a7d4e..0000000 --- a/cgi-bin/add.py +++ /dev/null @@ -1,63 +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 config -from config import Config -import path -from path import Path -import time - -sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) -print("Content-type:text/html\n") - -form = cgi.FieldStorage() -action = form.getvalue('action') -if action == "modify": - whisper_content = form.getvalue('whisper_content') - if whisper_content == None: - whisper_content = "" - whisper_id = form.getvalue('whisper_id') - db = Connect.produce() - cursor = db.cursor() - query = "update whisper set content = '{0}' where id = {1}".format(pymysql.escape_string(whisper_content), whisper_id) - cursor.execute(query) - db.commit() - cursor.close() - db.close() - _url = Config.get("route", "url") - redirect = """ - - - - - - """.format(_url) - print(redirect) -elif action == "new": - whisper_content = form.getvalue('whisper_content') - if whisper_content == None: - whisper_content = "" - t = time.time() - db = Connect.produce() - cursor = db.cursor() - query = "insert into whisper (content, date) values ('{0}', '{1}')".format(pymysql.escape_string(whisper_content), t) - cursor.execute(query) - db.commit() - cursor.close() - db.close() - _url = Config.get("route", "url") - redirect = """ - - - - - - """.format(_url) - print(redirect) -else: - print("Invalid action") \ No newline at end of file -- cgit v1.1-26-g67d0