-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
68 lines (49 loc) · 1.7 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from flask import Flask, render_template, request, jsonify
from inviteArr import plexMigrationTools
from plexapi import config
import os
import logging
if os.getenv("PLEXAPI_CONFIG_PATH"):
pass
else:
PLEXAPI_CONFIG_PATH = os.getcwd() + "/config.ini"
running_config = config.PlexConfig(PLEXAPI_CONFIG_PATH)
dry_run_value = running_config.data["migration_options"]["dry_run"].lower() == "true"
app = Flask(__name__)
migration = plexMigrationTools(
running_config.data["auth"]["myplex_username"],
running_config.data["auth"]["myplex_password"],
running_config.data["auth"]["server_baseurl"],
running_config.data["auth"]["server_token"],
running_config.data["auth"]["server_baseurl"],
dry_run_value,
)
print(migration.DRY_RUN)
if migration.DRY_RUN == True:
logging.info("I'm in the main app and Dry Run is enabled")
if migration.DRY_RUN == False:
logging.info("I'm in the main app and Dry Run is disabled")
@app.route("/")
def index():
current_server = migration.PLEX_SERVER
return render_template("index.html", current_server=current_server)
@app.route("/getUsers", methods=["GET"])
def get_users():
users = migration.getUsers()
return render_template("users.html", users=users)
@app.route("/backup", methods=["GET"])
def backup():
migration.backupPlex()
return "Backup done!"
@app.route("/invitePage", methods=["GET"])
def invite_page():
return render_template("invite.html")
@app.route("/invite", methods=["POST"])
def invite_user():
email = request.form.get("email")
if not email:
return "Email is required!", 400
migration.inviteUser(email)
return f"Invitation sent to {email}!"
if __name__ == "__main__":
app.run(debug=True)