test
This commit is contained in:
parent
4b0f33ae26
commit
1e22cfcb4a
57
Flask/app.py
57
Flask/app.py
@ -7,7 +7,7 @@ from flask_login import LoginManager, UserMixin, login_required, login_user, log
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
global password
|
global password
|
||||||
with open("./user_data/flask.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/flask.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
|
|
||||||
password = data["password"]
|
password = data["password"]
|
||||||
@ -15,7 +15,7 @@ secret = data["secret"]
|
|||||||
if secret == "":
|
if secret == "":
|
||||||
import secrets
|
import secrets
|
||||||
secret = secrets.token_hex()
|
secret = secrets.token_hex()
|
||||||
with open("./user_data/flask.json", "w") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/flask.json", "w") as inFile:
|
||||||
data = {
|
data = {
|
||||||
"password": password,
|
"password": password,
|
||||||
"secret": secret
|
"secret": secret
|
||||||
@ -31,12 +31,12 @@ scheduler.start()
|
|||||||
|
|
||||||
def start_ms(i):
|
def start_ms(i):
|
||||||
print("\033[32m" + f"Starting config {i}" + "\033[0m")
|
print("\033[32m" + f"Starting config {i}" + "\033[0m")
|
||||||
subprocess.Popen(["python3",'-u' ,"./V6.py", "-c", i])
|
subprocess.Popen(["python3",'-u' ,"/app/MsRewards-Reborn/V6.py", "-c", i])
|
||||||
|
|
||||||
|
|
||||||
TriggerDict = {}
|
TriggerDict = {}
|
||||||
def update_jobs():
|
def update_jobs():
|
||||||
with open("./user_data/configs.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
for i in configs:
|
for i in configs:
|
||||||
h, m = configs[i]["time"].split(":")
|
h, m = configs[i]["time"].split(":")
|
||||||
@ -119,7 +119,7 @@ def change_password():
|
|||||||
global password
|
global password
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
password = request.form["password"]
|
password = request.form["password"]
|
||||||
with open("./user_data/flask.json", "w") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/flask.json", "w") as inFile:
|
||||||
data = {
|
data = {
|
||||||
"password": password,
|
"password": password,
|
||||||
"secret": secret
|
"secret": secret
|
||||||
@ -154,21 +154,21 @@ def dev():
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main():
|
def main():
|
||||||
with open("./user_data/configs.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
return(render_template("override.html", data=configs))
|
return(render_template("override.html", data=configs))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/discord/")
|
@app.route("/discord/")
|
||||||
def discord_get():
|
def discord_get():
|
||||||
with open("./user_data/discord.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/discord.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
return(render_template("discord.html", data=data, len=maxi(data)))
|
return(render_template("discord.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/discord/", methods=["post"])
|
@app.route("/discord/", methods=["post"])
|
||||||
def discord_post():
|
def discord_post():
|
||||||
with open("./user_data/discord.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/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" :
|
if action['DISCORD'] == "delete" :
|
||||||
@ -190,14 +190,14 @@ def discord_post():
|
|||||||
name = action["name"] if action["name"] else f"unnamed{action['select']}"
|
name = action["name"] if action["name"] else f"unnamed{action['select']}"
|
||||||
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
|
data[config] = {"errorsL" : errorsL, "errorsT": errorsT, "successT": successT, "successL": successL, "name": name}
|
||||||
|
|
||||||
with open("./user_data/discord.json", "w") as outFile:
|
with open("/app/MsRewards-Reborn/user_data/discord.json", "w") as outFile:
|
||||||
json.dump(data, outFile)
|
json.dump(data, outFile)
|
||||||
return(render_template("discord.html", data=data, len=maxi(data)))
|
return(render_template("discord.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/dev/")
|
@app.route("/dev/")
|
||||||
def dev2():
|
def dev2():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
|
||||||
j = json.load(inFile)
|
j = json.load(inFile)
|
||||||
new_proxy = {"address": "ADDRESS", "port": "PORT", "name":"NAME"}
|
new_proxy = {"address": "ADDRESS", "port": "PORT", "name":"NAME"}
|
||||||
max_index = 0
|
max_index = 0
|
||||||
@ -210,14 +210,14 @@ def dev2():
|
|||||||
break
|
break
|
||||||
j[f"{max_index}"] = new_proxy
|
j[f"{max_index}"] = new_proxy
|
||||||
print(j)
|
print(j)
|
||||||
with open("./user_data/proxy.json", "w") as outfile:
|
with open("/app/MsRewards-Reborn/user_data/proxy.json", "w") as outfile:
|
||||||
json.dump(j, outfile)
|
json.dump(j, outfile)
|
||||||
return(render_template("dev.html"))
|
return(render_template("dev.html"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/settings/")
|
@app.route("/settings/")
|
||||||
def settings_get():
|
def settings_get():
|
||||||
with open("./user_data/settings.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/settings.json", "r") as inFile:
|
||||||
settings = json.load(inFile)
|
settings = json.load(inFile)
|
||||||
return(render_template("settings.html", data=settings))
|
return(render_template("settings.html", data=settings))
|
||||||
|
|
||||||
@ -227,21 +227,21 @@ def settings_post():
|
|||||||
settings = {}
|
settings = {}
|
||||||
action = request.form
|
action = request.form
|
||||||
settings['avatarlink'] = action["avatarlink"]
|
settings['avatarlink'] = action["avatarlink"]
|
||||||
with open("./user_data/settings.json", "w") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/settings.json", "w") as inFile:
|
||||||
json.dump(settings, inFile)
|
json.dump(settings, inFile)
|
||||||
return(render_template("settings.html", data=settings))
|
return(render_template("settings.html", data=settings))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/proxy/")
|
@app.route("/proxy/")
|
||||||
def proxy_get():
|
def proxy_get():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
|
||||||
j = json.load(inFile)
|
j = json.load(inFile)
|
||||||
return(render_template("proxy.html", data=j, len=maxi(j)))
|
return(render_template("proxy.html", data=j, len=maxi(j)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/proxy/", methods=["post"])
|
@app.route("/proxy/", methods=["post"])
|
||||||
def proxy_post():
|
def proxy_post():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
action = request.form
|
action = request.form
|
||||||
print(action)
|
print(action)
|
||||||
@ -258,21 +258,21 @@ def proxy_post():
|
|||||||
except :
|
except :
|
||||||
print("error : probably bad config")
|
print("error : probably bad config")
|
||||||
|
|
||||||
with open("./user_data/proxy.json", "w") as outFile:
|
with open("/app/MsRewards-Reborn/user_data/proxy.json", "w") as outFile:
|
||||||
json.dump(data, outFile)
|
json.dump(data, outFile)
|
||||||
return(render_template("proxy.html", data=data, len=maxi(data)))
|
return(render_template("proxy.html", data=data, len=maxi(data)))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/override/")
|
@app.route("/override/")
|
||||||
def override_get():
|
def override_get():
|
||||||
with open("./user_data/configs.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
return(render_template("override.html", data=configs))
|
return(render_template("override.html", data=configs))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/override/", methods=["post"])
|
@app.route("/override/", methods=["post"])
|
||||||
def override_post():
|
def override_post():
|
||||||
with open("./user_data/configs.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
|
|
||||||
data = dict(request.form)
|
data = dict(request.form)
|
||||||
@ -286,7 +286,7 @@ def override_post():
|
|||||||
configs[i]["time"] = data[f"time{i}"]
|
configs[i]["time"] = data[f"time{i}"]
|
||||||
configs[i]["enabled"] = data[f"switch{i}"] == "on"
|
configs[i]["enabled"] = data[f"switch{i}"] == "on"
|
||||||
|
|
||||||
with open("./user_data/configs.json", "w") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "w") as inFile:
|
||||||
json.dump(configs, inFile)
|
json.dump(configs, inFile)
|
||||||
update_jobs()
|
update_jobs()
|
||||||
return(render_template("override.html", data=configs))
|
return(render_template("override.html", data=configs))
|
||||||
@ -294,7 +294,7 @@ def override_post():
|
|||||||
|
|
||||||
@app.route("/database/")
|
@app.route("/database/")
|
||||||
def database_get():
|
def database_get():
|
||||||
with open("./user_data/database.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/database.json", "r") as inFile:
|
||||||
database = json.load(inFile)
|
database = json.load(inFile)
|
||||||
return(render_template("database.html", data = database))
|
return(render_template("database.html", data = database))
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ def database_post():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with open("./user_data/database.json", "w") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/database.json", "w") as inFile:
|
||||||
json.dump(data, inFile)
|
json.dump(data, inFile)
|
||||||
|
|
||||||
return(render_template("database.html", data = data))
|
return(render_template("database.html", data = data))
|
||||||
@ -324,11 +324,11 @@ def database_post():
|
|||||||
|
|
||||||
@app.route("/config/")
|
@app.route("/config/")
|
||||||
def config_get():
|
def config_get():
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/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("/app/MsRewards-Reborn/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("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
||||||
|
|
||||||
@ -336,11 +336,11 @@ def config_get():
|
|||||||
@app.route("/config/", methods=["POST"])
|
@app.route("/config/", methods=["POST"])
|
||||||
def config_post():
|
def config_post():
|
||||||
action = request.form
|
action = request.form
|
||||||
with open("./user_data/proxy.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/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("/app/MsRewards-Reborn/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("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
configs = json.load(inFile)
|
configs = json.load(inFile)
|
||||||
|
|
||||||
comptes = {
|
comptes = {
|
||||||
@ -359,7 +359,7 @@ def config_post():
|
|||||||
"enabled":"False",
|
"enabled":"False",
|
||||||
"accounts": comptes
|
"accounts": comptes
|
||||||
}
|
}
|
||||||
with open("./user_data/configs.json", "w") as outFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "w") as outFile:
|
||||||
json.dump(configs, outFile)
|
json.dump(configs, outFile)
|
||||||
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
return(render_template("config.html", data=configs, discords=discords, proxys=proxys, configs=configs, len=maxi(configs)))
|
||||||
|
|
||||||
@ -373,4 +373,5 @@ def maxi(dict):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
update_jobs()
|
||||||
app.run(host='0.0.0.0', port=1234, debug=True)
|
app.run(host='0.0.0.0', port=1234, debug=True)
|
Loading…
Reference in New Issue
Block a user