oh boy
This commit is contained in:
parent
b201c68aa9
commit
08b593eeb9
99
Flask/app.py
99
Flask/app.py
|
@ -137,7 +137,7 @@ def main():
|
|||
def discord_get():
|
||||
with open("./user_data/discord.json", "r") as 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"])
|
||||
|
@ -145,7 +145,9 @@ def discord_post():
|
|||
with open("./user_data/discord.json", "r") as inFile:
|
||||
data = json.load(inFile)
|
||||
action = request.form
|
||||
|
||||
if action['DISCORD'] == "delete" :
|
||||
data.pop(action["select"], None)
|
||||
else :
|
||||
config = action["select"]
|
||||
successL = action["successL"]
|
||||
try :
|
||||
|
@ -164,7 +166,7 @@ def discord_post():
|
|||
|
||||
with open("./user_data/discord.json", "w") as 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/")
|
||||
|
@ -193,6 +195,7 @@ def settings_get():
|
|||
settings = json.load(inFile)
|
||||
return(render_template("settings.html", data=settings))
|
||||
|
||||
|
||||
@app.route("/settings/", methods=["post"])
|
||||
def settings_post():
|
||||
settings = {}
|
||||
|
@ -207,7 +210,7 @@ def settings_post():
|
|||
def proxy_get():
|
||||
with open("./user_data/proxy.json", "r") as 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"])
|
||||
|
@ -215,6 +218,11 @@ def proxy_post():
|
|||
with open("./user_data/proxy.json", "r") as inFile:
|
||||
data = json.load(inFile)
|
||||
action = request.form
|
||||
print(action)
|
||||
if action['PROXY'] == "delete" :
|
||||
print(action)
|
||||
data.pop(action["select"], None)
|
||||
else :
|
||||
try :
|
||||
config = action["select"]
|
||||
address = action["address"]
|
||||
|
@ -226,18 +234,36 @@ def proxy_post():
|
|||
|
||||
with open("./user_data/proxy.json", "w") as 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/")
|
||||
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"])
|
||||
def override():
|
||||
subprocess.run(["python3", "./V6.py", "-v", "2345"])
|
||||
return(render_template("override.html"))
|
||||
with open("./user_data/configs.json", "r") as inFile:
|
||||
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/")
|
||||
|
@ -270,19 +296,19 @@ def database_post():
|
|||
return(render_template("database.html", data = data))
|
||||
|
||||
|
||||
@app.route("/accounts/")
|
||||
def accounts_get():
|
||||
@app.route("/config/")
|
||||
def config_get():
|
||||
with open("./user_data/proxy.json", "r") as inFile:
|
||||
proxys = json.load(inFile)
|
||||
with open("./user_data/discord.json", "r") as inFile:
|
||||
discords = json.load(inFile)
|
||||
with open("./user_data/configs.json", "r") as 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"])
|
||||
def accounts_post():
|
||||
@app.route("/config/", methods=["POST"])
|
||||
def config_post():
|
||||
action = request.form
|
||||
with open("./user_data/proxy.json", "r") as inFile:
|
||||
proxys = json.load(inFile)
|
||||
|
@ -303,49 +329,22 @@ def accounts_post():
|
|||
"name" : action["name"] if action["name"] != "" else f"unnamed{action['config']}",
|
||||
"proxy": action["proxy"],
|
||||
"discord": action["discord"],
|
||||
"accounts": comptes
|
||||
"time":"",
|
||||
"enabled":"False",
|
||||
"config": comptes
|
||||
}
|
||||
with open("./user_data/configs.json", "w") as 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__':
|
||||
app.run(host='0.0.0.0', port=3456, debug=True)
|
|
@ -137,6 +137,7 @@ input[type=password] {
|
|||
|
||||
button:hover{
|
||||
border: 2px solid white;
|
||||
cursor: pointer;
|
||||
}
|
||||
input:hover{
|
||||
border: 2px solid white;
|
||||
|
@ -215,9 +216,10 @@ input[type=checkbox]{
|
|||
height: 0;
|
||||
width: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
padding: 8px;
|
||||
margin: auto;
|
||||
cursor: pointer;
|
||||
text-indent: -9999px;
|
||||
|
@ -274,3 +276,26 @@ select {
|
|||
select:hover {
|
||||
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>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="selected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="selected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -40,7 +40,7 @@
|
|||
{%if not current_user.is_authenticated %}
|
||||
<button class="unselected" onclick="location.href = '/login';">login</button>
|
||||
{% else %}
|
||||
<form method="post" action="/accounts/">
|
||||
<form method="post" action="/config/">
|
||||
|
||||
|
||||
<table>
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = 'accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = 'config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -73,12 +73,17 @@
|
|||
<td class="comlumn-name">Failure Link</td>
|
||||
<td><input type="text" id="errorsL" name="errorsL" value=""></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" name="DISCORD" id="submit" value="Create !" class="button"/></td>
|
||||
<td class="comlumn-name"></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>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
function changecat(value) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -39,14 +39,30 @@
|
|||
|
||||
{%if not current_user.is_authenticated %}
|
||||
<button class="unselected" onclick="location.href = '/login';">login</button>
|
||||
{% else %}
|
||||
|
||||
|
||||
{% else %}
|
||||
|
||||
|
||||
<h1>Not Implemented, watch terminal</h1>
|
||||
<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>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -68,15 +68,16 @@
|
|||
<td class="comlumn-name">port : </td>
|
||||
<td><input type="text" name="port" value="" id="port"></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" name="data" id="submit" value="Create" class="button"/></td>
|
||||
<td class="comlumn-name"></td>
|
||||
<td style="width:60%;"><input type="submit" name="PROXY" id="submit" value="Create !" class="button" style="width:90%;"/></td>
|
||||
<td style="padding-right: 20px;"><input type="submit" name="PROXY" id="submit" value="delete" class="button"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button class="unselected" onclick="location.href = '/accounts';">accounts</button>
|
||||
<button class="unselected" onclick="location.href = '/config';">config</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in New Issue