mirror of
https://gitlab.com/octtspacc/PlainDiscuss
synced 2025-06-05 22:09:15 +02:00
First commit
This commit is contained in:
31
Source/Form.html
Normal file
31
Source/Form.html
Normal file
@ -0,0 +1,31 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="Style.css">
|
||||
</head>
|
||||
<body>
|
||||
<form action="/Comments" method="get">
|
||||
<div>
|
||||
<h3>Comments</h3>
|
||||
<button type="submit" name="Action" value="Delete">Delete Selected</button>
|
||||
<button type="submit" name="Action" value="Login">Admin Login</button>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label>Your Secret Key (Optional):</label>
|
||||
<span><input type="password" name="SecretKey"></span>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label>CAPTCHA:</label>
|
||||
<span><input type="text" name="CAPTCHA"></span>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
<label>Your Reply:</label>
|
||||
<button type="submit" name="Action" value="Post">Post as New Comment</button>
|
||||
<textarea name="Comment"></textarea>
|
||||
</div>
|
||||
<br>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
66
Source/Server.py
Executable file
66
Source/Server.py
Executable file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
""" =============================== |
|
||||
| PlainDiscuss |
|
||||
| |
|
||||
| Licensed under the AGPLv3 license |
|
||||
| Copyright (C) 2022, OctoSpacc |
|
||||
| =============================== """
|
||||
|
||||
import json
|
||||
from ast import literal_eval
|
||||
from flask import Flask, request, send_file
|
||||
#from APIConfig import *
|
||||
|
||||
App = Flask(__name__)
|
||||
|
||||
def ReadFile(p):
|
||||
try:
|
||||
with open(p, 'r') as f:
|
||||
return f.read()
|
||||
except Exception:
|
||||
print("Error reading file {}".format(p))
|
||||
return None
|
||||
|
||||
def WriteFile(p, c):
|
||||
try:
|
||||
with open(p, 'w') as f:
|
||||
f.write(c)
|
||||
return True
|
||||
except Exception:
|
||||
print("Error writing file {}".format(p))
|
||||
return False
|
||||
|
||||
def SetConfig():
|
||||
Config = {
|
||||
'Development': False,
|
||||
'Port': 8080}
|
||||
File = ReadFile('Config.json')
|
||||
if File:
|
||||
File = json.loads(File)
|
||||
for i in File:
|
||||
if i in File and File[i]:
|
||||
Config[i] = File[i]
|
||||
return Config
|
||||
|
||||
def HandlePost(Req):
|
||||
Data = Req.get_json()
|
||||
|
||||
@App.route('/Test.html')
|
||||
def Test():
|
||||
return send_file('Test.html')
|
||||
|
||||
@App.route('/Comments', methods=['GET' 'POST'])
|
||||
def Comments():
|
||||
if request.method == 'GET':
|
||||
pass
|
||||
if request.method == 'POST':
|
||||
return HandlePost(request)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Config = SetConfig()
|
||||
|
||||
if Config['Development']:
|
||||
App.run(host='0.0.0.0', port=Config['Port'], debug=True)
|
||||
else:
|
||||
from waitress import serve
|
||||
serve(App, host='0.0.0.0', port=Config['Port'])
|
15
Source/Style.css
Normal file
15
Source/Style.css
Normal file
@ -0,0 +1,15 @@
|
||||
Input, TextArea {
|
||||
Width: 100%;
|
||||
}
|
||||
Span {
|
||||
Display: Block;
|
||||
Overflow: Hidden;
|
||||
}
|
||||
Label{
|
||||
Float: Left;
|
||||
Padding-Right: 8px;
|
||||
}
|
||||
TextArea {
|
||||
Width: 100%;
|
||||
Height: 30%;
|
||||
}
|
Reference in New Issue
Block a user