This commit is contained in:
parent
c92abf2ee3
commit
4edce022bd
|
@ -0,0 +1 @@
|
|||
Comments.db
|
|
@ -0,0 +1,31 @@
|
|||
CREATE TABLE IF NOT EXISTS "Users" (
|
||||
"ID" INTEGER NOT NULL UNIQUE,
|
||||
"Name" TEXT NOT NULL,
|
||||
"SecKey" TEXT NOT NULL UNIQUE,
|
||||
PRIMARY KEY("ID" AUTOINCREMENT)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "Sites" (
|
||||
"ID" INTEGER NOT NULL UNIQUE,
|
||||
"PubKey" TEXT NOT NULL UNIQUE,
|
||||
"SecKey" TEXT NOT NULL UNIQUE,
|
||||
PRIMARY KEY("ID" AUTOINCREMENT)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "Pages" (
|
||||
"ID" INTEGER NOT NULL UNIQUE,
|
||||
"Site" INTEGER NOT NULL,
|
||||
"Path" TEXT NOT NULL,
|
||||
PRIMARY KEY("ID" AUTOINCREMENT),
|
||||
FOREIGN KEY("Site") REFERENCES "Sites"("ID")
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "Comments" (
|
||||
"ID" INTEGER NOT NULL UNIQUE,
|
||||
"User" INTEGER NOT NULL,
|
||||
"Page" TEXT NOT NULL,
|
||||
"Reply" INTEGER,
|
||||
PRIMARY KEY("ID" AUTOINCREMENT),
|
||||
FOREIGN KEY("Page") REFERENCES "Pages"("ID"),
|
||||
FOREIGN KEY("User") REFERENCES "Users"("ID")
|
||||
);
|
|
@ -1,5 +1,6 @@
|
|||
<div id="PlainDiscussComment{ID}">
|
||||
<h5>{User}, {Date}, <a href="#PlainDiscussComment{ID}">#{ID}</a></h5>
|
||||
<input type="checkbox" name="Select" value="{ID}">
|
||||
<button type="submit" name="Report" value="{ID}">Report</button>
|
||||
<button type="submit" name="Reply" value="{ID}">Reply to</button>
|
||||
</div>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
| =============================== """
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
from ast import literal_eval
|
||||
from flask import Flask, request, send_file
|
||||
#from APIConfig import *
|
||||
|
@ -30,7 +31,7 @@ def WriteFile(p, c):
|
|||
print("Error writing file {}".format(p))
|
||||
return False
|
||||
|
||||
def SetConfig():
|
||||
def GetConfig():
|
||||
Config = {
|
||||
'Development': False,
|
||||
'Port': 8080}
|
||||
|
@ -42,10 +43,18 @@ def SetConfig():
|
|||
Config[i] = File[i]
|
||||
return Config
|
||||
|
||||
def InitDB():
|
||||
for i in ReadFile('Source/Comments.sql').split(';'):
|
||||
DB.cursor().execute(i)
|
||||
DB.commit()
|
||||
|
||||
def GetDB():
|
||||
return sqlite3.connect('Comments.db')
|
||||
|
||||
def GetComments():
|
||||
return [0,0,0]
|
||||
|
||||
def PatchHTML():
|
||||
def PatchHTML(Data):
|
||||
Base = ReadFile('Source/Main.html')
|
||||
FormMain = ReadFile('Source/Form.Main.html')
|
||||
FormComment = ReadFile('Source/Form.Comment.html')
|
||||
|
@ -60,17 +69,11 @@ def PatchHTML():
|
|||
return Base.format(FormMain + Comments)
|
||||
|
||||
def Get(Req):
|
||||
Data = Req.args
|
||||
print(Data.get('Site'))
|
||||
print(Data.get('Page'))
|
||||
print(Data.get('User'))
|
||||
print(Data.get('CAPTCHA'))
|
||||
print(Data.get('Comment'))
|
||||
print(Data.get('SecretKey'))
|
||||
print(Data.get('Action'))
|
||||
print(Data.get('Reply'))
|
||||
print(Data.get('Report'))
|
||||
return PatchHTML()
|
||||
Data = {}
|
||||
for i in ['Site','Page','User','CAPTCHA','Comment','SecretKey','Select','Action','Reply','Report']:
|
||||
Data.update({i:Req.args.get(i)})
|
||||
print(Req.args.get(i))
|
||||
return PatchHTML(Data)
|
||||
|
||||
def Post(Req):
|
||||
Data = Req.get_json()
|
||||
|
@ -89,7 +92,9 @@ def Comments():
|
|||
return Post(Req)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Config = SetConfig()
|
||||
Config = GetConfig()
|
||||
DB = GetDB()
|
||||
InitDB()
|
||||
|
||||
if Config['Development']:
|
||||
App.run(host='0.0.0.0', port=Config['Port'], debug=True)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
flask
|
||||
waitress
|
Loading…
Reference in New Issue