oh boy
This commit is contained in:
parent
b201c68aa9
commit
08b593eeb9
145
Flask/app.py
145
Flask/app.py
@ -137,7 +137,7 @@ def main():
|
|||||||
def discord_get():
|
def discord_get():
|
||||||
with open("./user_data/discord.json", "r") as inFile:
|
with open("./user_data/discord.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
return(render_template("discord.html", data=data, len=len(data)))
|
return(render_template("discord.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/discord/", methods=["post"])
|
@app.route("/discord/", methods=["post"])
|
||||||
@ -145,26 +145,28 @@ def discord_post():
|
|||||||
with open("./user_data/discord.json", "r") as inFile:
|
with open("./user_data/discord.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
action = request.form
|
action = request.form
|
||||||
|
if action['DISCORD'] == "delete" :
|
||||||
config = action["select"]
|
data.pop(action["select"], None)
|
||||||
successL = action["successL"]
|
else :
|
||||||
try :
|
config = action["select"]
|
||||||
a = action["successT"]
|
successL = action["successL"]
|
||||||
successT = "True"
|
try :
|
||||||
except:
|
a = action["successT"]
|
||||||
successT = "False"
|
successT = "True"
|
||||||
try :
|
except:
|
||||||
a = action["errorsT"]
|
successT = "False"
|
||||||
errorsT = "True"
|
try :
|
||||||
except:
|
a = action["errorsT"]
|
||||||
errorsT = "False"
|
errorsT = "True"
|
||||||
errorsL = action["errorsL"]
|
except:
|
||||||
name = action["name"] if action["name"] else f"unnamed{action['select']}"
|
errorsT = "False"
|
||||||
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
|
errorsL = action["errorsL"]
|
||||||
|
name = action["name"] if action["name"] else f"unnamed{action['select']}"
|
||||||
|
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
|
||||||
|
|
||||||
with open("./user_data/discord.json", "w") as outFile:
|
with open("./user_data/discord.json", "w") as outFile:
|
||||||
json.dump(data, outFile)
|
json.dump(data, outFile)
|
||||||
return(render_template("discord.html", data=data, len=len(data)))
|
return(render_template("discord.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/dev/")
|
@app.route("/dev/")
|
||||||
@ -193,6 +195,7 @@ def settings_get():
|
|||||||
settings = json.load(inFile)
|
settings = json.load(inFile)
|
||||||
return(render_template("settings.html", data=settings))
|
return(render_template("settings.html", data=settings))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/settings/", methods=["post"])
|
@app.route("/settings/", methods=["post"])
|
||||||
def settings_post():
|
def settings_post():
|
||||||
settings = {}
|
settings = {}
|
||||||
@ -207,7 +210,7 @@ def settings_post():
|
|||||||
def proxy_get():
|
def proxy_get():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("./user_data/proxy.json", "r") as inFile:
|
||||||
j = json.load(inFile)
|
j = json.load(inFile)
|
||||||
return(render_template("proxy.html", data=j, len=len(j)))
|
return(render_template("proxy.html", data=j, len=maxi(j)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/proxy/", methods=["post"])
|
@app.route("/proxy/", methods=["post"])
|
||||||
@ -215,29 +218,52 @@ def proxy_post():
|
|||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("./user_data/proxy.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
action = request.form
|
action = request.form
|
||||||
try :
|
print(action)
|
||||||
config = action["select"]
|
if action['PROXY'] == "delete" :
|
||||||
address = action["address"]
|
print(action)
|
||||||
port = action["port"]
|
data.pop(action["select"], None)
|
||||||
name = action["name"] if action["name"] else f"@unnamed{action['select']}"
|
else :
|
||||||
data[config] = {"address" : address, "port": port, "name": name}
|
try :
|
||||||
except :
|
config = action["select"]
|
||||||
print("error : probably bad config")
|
address = action["address"]
|
||||||
|
port = action["port"]
|
||||||
|
name = action["name"] if action["name"] else f"@unnamed{action['select']}"
|
||||||
|
data[config] = {"address" : address, "port": port, "name": name}
|
||||||
|
except :
|
||||||
|
print("error : probably bad config")
|
||||||
|
|
||||||
with open("./user_data/proxy.json", "w") as outFile:
|
with open("./user_data/proxy.json", "w") as outFile:
|
||||||
json.dump(data, outFile)
|
json.dump(data, outFile)
|
||||||
return(render_template("proxy.html", data=data, len=len(data)))
|
return(render_template("proxy.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/override/")
|
@app.route("/override/")
|
||||||
def override_get():
|
def override_get():
|
||||||
return(render_template("override.html"))
|
with open("./user_data/configs.json", "r") as inFile:
|
||||||
|
configs = json.load(inFile)
|
||||||
|
return(render_template("override.html", data=configs))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/override/", methods=["post"])
|
@app.route("/override/", methods=["post"])
|
||||||
def override():
|
def override():
|
||||||
subprocess.run(["python3", "./V6.py", "-v", "2345"])
|
with open("./user_data/configs.json", "r") as inFile:
|
||||||
return(render_template("override.html"))
|
configs = json.load(inFile)
|
||||||
|
|
||||||
|
data = dict(request.form)
|
||||||
|
for i in configs:
|
||||||
|
try :
|
||||||
|
data[f'switch{i}']
|
||||||
|
except :
|
||||||
|
data[f'switch{i}'] = "off"
|
||||||
|
|
||||||
|
for i in configs:
|
||||||
|
configs[i]["time"] = data[f"time{i}"]
|
||||||
|
configs[i]["enabled"] = data[f"switch{i}"] == "on"
|
||||||
|
|
||||||
|
with open("./user_data/configs.json", "w") as inFile:
|
||||||
|
json.dump(configs, inFile)
|
||||||
|
|
||||||
|
return(render_template("override.html", data=configs))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/database/")
|
@app.route("/database/")
|
||||||
@ -270,19 +296,19 @@ def database_post():
|
|||||||
return(render_template("database.html", data = data))
|
return(render_template("database.html", data = data))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/accounts/")
|
@app.route("/config/")
|
||||||
def accounts_get():
|
def config_get():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("./user_data/proxy.json", "r") as inFile:
|
||||||
proxys = json.load(inFile)
|
proxys = json.load(inFile)
|
||||||
with open("./user_data/discord.json", "r") as inFile:
|
with open("./user_data/discord.json", "r") as inFile:
|
||||||
discords = json.load(inFile)
|
discords = json.load(inFile)
|
||||||
with open("./user_data/configs.json", "r") as inFile:
|
with open("./user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
return(render_template("accounts.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=len(configs)))
|
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/accounts/", methods=["POST"])
|
@app.route("/config/", methods=["POST"])
|
||||||
def accounts_post():
|
def config_post():
|
||||||
action = request.form
|
action = request.form
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("./user_data/proxy.json", "r") as inFile:
|
||||||
proxys = json.load(inFile)
|
proxys = json.load(inFile)
|
||||||
@ -303,49 +329,22 @@ def accounts_post():
|
|||||||
"name" : action["name"] if action["name"] != "" else f"unnamed{action['config']}",
|
"name" : action["name"] if action["name"] != "" else f"unnamed{action['config']}",
|
||||||
"proxy": action["proxy"],
|
"proxy": action["proxy"],
|
||||||
"discord": action["discord"],
|
"discord": action["discord"],
|
||||||
"accounts": comptes
|
"time":"",
|
||||||
|
"enabled":"False",
|
||||||
|
"config": comptes
|
||||||
}
|
}
|
||||||
with open("./user_data/configs.json", "w") as outFile:
|
with open("./user_data/configs.json", "w") as outFile:
|
||||||
json.dump(configs, outFile)
|
json.dump(configs, outFile)
|
||||||
return(render_template("accounts.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=len(configs)))
|
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
||||||
|
|
||||||
|
|
||||||
def read_config_txt(ligne):
|
|
||||||
f = open("./user_data/config.cfg", "r")
|
|
||||||
txt = f.readlines()
|
|
||||||
f.close()
|
|
||||||
if txt.count(txt) >1:
|
|
||||||
raise NameError("Fail")
|
|
||||||
|
|
||||||
for i in range(len(txt)) :
|
|
||||||
name = txt[i].split(" = ")[0]
|
|
||||||
if name == ligne:
|
|
||||||
ret = txt[i].split(" = ")[1]
|
|
||||||
|
|
||||||
f = open("./user_data/config.cfg", "w")
|
|
||||||
for i in txt :
|
|
||||||
f.write(i)
|
|
||||||
f.close()
|
|
||||||
return(ret.replace("\n", ""))
|
|
||||||
|
|
||||||
|
|
||||||
def edit_config_txt(ligne, contenu):
|
|
||||||
f = open("./user_data/config.cfg", "r")
|
|
||||||
txt = f.readlines()
|
|
||||||
f.close()
|
|
||||||
if txt.count(txt) >1:
|
|
||||||
raise NameError("Fail")
|
|
||||||
|
|
||||||
for i in range(len(txt)) :
|
|
||||||
name = txt[i].split(" = ")[0]
|
|
||||||
if name == ligne:
|
|
||||||
txt[i] = name + " = " + str(contenu) + "\n"
|
|
||||||
|
|
||||||
f = open("./user_data/config.cfg", "w")
|
|
||||||
for i in txt :
|
|
||||||
f.write(i)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
def maxi(dict):
|
||||||
|
m = 0
|
||||||
|
for i in dict :
|
||||||
|
if int(i) >= m:
|
||||||
|
m = int(i)
|
||||||
|
return(m+1)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=3456, debug=True)
|
app.run(host='0.0.0.0', port=3456, debug=True)
|
@ -137,6 +137,7 @@ input[type=password] {
|
|||||||
|
|
||||||
button:hover{
|
button:hover{
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
input:hover{
|
input:hover{
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
@ -215,9 +216,10 @@ input[type=checkbox]{
|
|||||||
height: 0;
|
height: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
|
padding: 8px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-indent: -9999px;
|
text-indent: -9999px;
|
||||||
@ -274,3 +276,26 @@ select {
|
|||||||
select:hover {
|
select:hover {
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
input[type="time"] {
|
||||||
|
width: 70%;
|
||||||
|
padding: 8px 12px;
|
||||||
|
margin: 8px 0;
|
||||||
|
background-color: #212121;
|
||||||
|
border: 2px solid grey;
|
||||||
|
border-radius: 4px;
|
||||||
|
outline: none;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="time"]::-webkit-calendar-picker-indicator {
|
||||||
|
filter: invert(1);
|
||||||
|
opacity: 0.7;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="time"]::-webkit-calendar-picker-indicator:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="selected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="selected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -40,7 +40,7 @@
|
|||||||
{%if not current_user.is_authenticated %}
|
{%if not current_user.is_authenticated %}
|
||||||
<button class="unselected" onclick="location.href = '/login';">login</button>
|
<button class="unselected" onclick="location.href = '/login';">login</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<form method="post" action="/accounts/">
|
<form method="post" action="/config/">
|
||||||
|
|
||||||
|
|
||||||
<table>
|
<table>
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = 'accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = 'config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -73,12 +73,17 @@
|
|||||||
<td class="comlumn-name">Failure Link</td>
|
<td class="comlumn-name">Failure Link</td>
|
||||||
<td><input type="text" id="errorsL" name="errorsL" value=""></td>
|
<td><input type="text" id="errorsL" name="errorsL" value=""></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td class="comlumn-name"></td>
|
||||||
<td><input type="submit" name="DISCORD" id="submit" value="Create !" class="button"/></td>
|
<td style="width:60%;"><input type="submit" name="DISCORD" id="submit" value="Create !" class="button" style="width:90%;"/></td>
|
||||||
|
<td style="padding-right: 20px;">
|
||||||
|
<input type="submit" name="DISCORD" id="submit" value="delete" class="button"/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
<script>
|
<script>
|
||||||
function changecat(value) {
|
function changecat(value) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -39,14 +39,30 @@
|
|||||||
|
|
||||||
{%if not current_user.is_authenticated %}
|
{%if not current_user.is_authenticated %}
|
||||||
<button class="unselected" onclick="location.href = '/login';">login</button>
|
<button class="unselected" onclick="location.href = '/login';">login</button>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
|
|
||||||
<h1>Not Implemented, watch terminal</h1>
|
|
||||||
<form method="post" action="/override/">
|
<form method="post" action="/override/">
|
||||||
<input type="submit" name="data" value="Run bot" class="button"/>
|
<table>
|
||||||
|
{% for i in data %}
|
||||||
|
<tr>
|
||||||
|
<td>{{data[i]['name']}}</td>
|
||||||
|
<td>
|
||||||
|
<input type="time" id="{{i}}" name="time{{i}}" value="{{data[i]['time']}}">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" id="switch{{i}}" name="switch{{i}}" {{ "checked" if data[i]['enabled'] == True else "" }}/>
|
||||||
|
<label for="switch{{i}}">
|
||||||
|
Toggle
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<input type="submit" name="data" value="Update" class="button"/>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -68,13 +68,14 @@
|
|||||||
<td class="comlumn-name">port : </td>
|
<td class="comlumn-name">port : </td>
|
||||||
<td><input type="text" name="port" value="" id="port"></td>
|
<td><input type="text" name="port" value="" id="port"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</table>
|
||||||
<tr>
|
<table>
|
||||||
<td></td>
|
<tr>
|
||||||
<td><input type="submit" name="data" id="submit" value="Create" class="button"/></td>
|
<td class="comlumn-name"></td>
|
||||||
</tr>
|
<td style="width:60%;"><input type="submit" name="PROXY" id="submit" value="Create !" class="button" style="width:90%;"/></td>
|
||||||
</table>
|
<td style="padding-right: 20px;"><input type="submit" name="PROXY" id="submit" value="delete" class="button"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user