This commit is contained in:
piair 2023-06-25 09:22:22 +02:00
parent 4b0f33ae26
commit 1e22cfcb4a
2 changed files with 30 additions and 29 deletions

View File

@ -7,7 +7,7 @@ from flask_login import LoginManager, UserMixin, login_required, login_user, log
import json
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)
password = data["password"]
@ -15,7 +15,7 @@ secret = data["secret"]
if secret == "":
import secrets
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 = {
"password": password,
"secret": secret
@ -31,12 +31,12 @@ scheduler.start()
def start_ms(i):
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 = {}
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)
for i in configs:
h, m = configs[i]["time"].split(":")
@ -119,7 +119,7 @@ def change_password():
global password
if request.method == 'POST':
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 = {
"password": password,
"secret": secret
@ -154,21 +154,21 @@ def dev():
@app.route("/")
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)
return(render_template("override.html", data=configs))
@app.route("/discord/")
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)
return(render_template("discord.html", data=data, len=maxi(data)))
@app.route("/discord/", methods=["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)
action = request.form
if action['DISCORD'] == "delete" :
@ -190,14 +190,14 @@ def discord_post():
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("/app/MsRewards-Reborn/user_data/discord.json", "w") as outFile:
json.dump(data, outFile)
return(render_template("discord.html", data=data, len=maxi(data)))
@app.route("/dev/")
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)
new_proxy = {"address": "ADDRESS", "port": "PORT", "name":"NAME"}
max_index = 0
@ -210,14 +210,14 @@ def dev2():
break
j[f"{max_index}"] = new_proxy
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)
return(render_template("dev.html"))
@app.route("/settings/")
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)
return(render_template("settings.html", data=settings))
@ -227,21 +227,21 @@ def settings_post():
settings = {}
action = request.form
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)
return(render_template("settings.html", data=settings))
@app.route("/proxy/")
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)
return(render_template("proxy.html", data=j, len=maxi(j)))
@app.route("/proxy/", methods=["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)
action = request.form
print(action)
@ -258,21 +258,21 @@ def proxy_post():
except :
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)
return(render_template("proxy.html", data=data, len=maxi(data)))
@app.route("/override/")
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)
return(render_template("override.html", data=configs))
@app.route("/override/", methods=["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)
data = dict(request.form)
@ -286,7 +286,7 @@ def override_post():
configs[i]["time"] = data[f"time{i}"]
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)
update_jobs()
return(render_template("override.html", data=configs))
@ -294,7 +294,7 @@ def override_post():
@app.route("/database/")
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)
return(render_template("database.html", data = database))
@ -316,7 +316,7 @@ def database_post():
except:
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)
return(render_template("database.html", data = data))
@ -324,11 +324,11 @@ def database_post():
@app.route("/config/")
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)
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)
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)
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"])
def config_post():
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)
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)
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)
comptes = {
@ -359,7 +359,7 @@ def config_post():
"enabled":"False",
"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)
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__':
update_jobs()
app.run(host='0.0.0.0', port=1234, debug=True)

View File

@ -1 +1 @@
sudo docker build -t msrewards . && sudo docker run -p 1234:1234 -p 2345:2345 --shm-size=2gb --name MsRewards msrewards
sudo docker build -t msrewards . && sudo docker run -d --restart unless-stopped -p 1234:1234 -p 2345:2345 --shm-size=2gb --name MsRewards msrewards