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}">
|
<div id="PlainDiscussComment{ID}">
|
||||||
<h5>{User}, {Date}, <a href="#PlainDiscussComment{ID}">#{ID}</a></h5>
|
<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="Report" value="{ID}">Report</button>
|
||||||
<button type="submit" name="Reply" value="{ID}">Reply to</button>
|
<button type="submit" name="Reply" value="{ID}">Reply to</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
| =============================== """
|
| =============================== """
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import sqlite3
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
from flask import Flask, request, send_file
|
from flask import Flask, request, send_file
|
||||||
#from APIConfig import *
|
#from APIConfig import *
|
||||||
|
@ -30,11 +31,11 @@ def WriteFile(p, c):
|
||||||
print("Error writing file {}".format(p))
|
print("Error writing file {}".format(p))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def SetConfig():
|
def GetConfig():
|
||||||
Config = {
|
Config = {
|
||||||
'Development': False,
|
'Development': False,
|
||||||
'Port': 8080}
|
'Port': 8080}
|
||||||
File = ReadFile('Config.json')
|
File = ReadFile('Config.json')
|
||||||
if File:
|
if File:
|
||||||
File = json.loads(File)
|
File = json.loads(File)
|
||||||
for i in File:
|
for i in File:
|
||||||
|
@ -42,10 +43,18 @@ def SetConfig():
|
||||||
Config[i] = File[i]
|
Config[i] = File[i]
|
||||||
return Config
|
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():
|
def GetComments():
|
||||||
return [0,0,0]
|
return [0,0,0]
|
||||||
|
|
||||||
def PatchHTML():
|
def PatchHTML(Data):
|
||||||
Base = ReadFile('Source/Main.html')
|
Base = ReadFile('Source/Main.html')
|
||||||
FormMain = ReadFile('Source/Form.Main.html')
|
FormMain = ReadFile('Source/Form.Main.html')
|
||||||
FormComment = ReadFile('Source/Form.Comment.html')
|
FormComment = ReadFile('Source/Form.Comment.html')
|
||||||
|
@ -60,17 +69,11 @@ def PatchHTML():
|
||||||
return Base.format(FormMain + Comments)
|
return Base.format(FormMain + Comments)
|
||||||
|
|
||||||
def Get(Req):
|
def Get(Req):
|
||||||
Data = Req.args
|
Data = {}
|
||||||
print(Data.get('Site'))
|
for i in ['Site','Page','User','CAPTCHA','Comment','SecretKey','Select','Action','Reply','Report']:
|
||||||
print(Data.get('Page'))
|
Data.update({i:Req.args.get(i)})
|
||||||
print(Data.get('User'))
|
print(Req.args.get(i))
|
||||||
print(Data.get('CAPTCHA'))
|
return PatchHTML(Data)
|
||||||
print(Data.get('Comment'))
|
|
||||||
print(Data.get('SecretKey'))
|
|
||||||
print(Data.get('Action'))
|
|
||||||
print(Data.get('Reply'))
|
|
||||||
print(Data.get('Report'))
|
|
||||||
return PatchHTML()
|
|
||||||
|
|
||||||
def Post(Req):
|
def Post(Req):
|
||||||
Data = Req.get_json()
|
Data = Req.get_json()
|
||||||
|
@ -89,7 +92,9 @@ def Comments():
|
||||||
return Post(Req)
|
return Post(Req)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Config = SetConfig()
|
Config = GetConfig()
|
||||||
|
DB = GetDB()
|
||||||
|
InitDB()
|
||||||
|
|
||||||
if Config['Development']:
|
if Config['Development']:
|
||||||
App.run(host='0.0.0.0', port=Config['Port'], debug=True)
|
App.run(host='0.0.0.0', port=Config['Port'], debug=True)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
flask
|
||||||
|
waitress
|
Loading…
Reference in New Issue