Skip to content

Commit 2fdd0da

Browse files
nerzhulsfan5
authored andcommittedJul 18, 2015
Use ternary operator when possible
1 parent c26c42b commit 2fdd0da

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed
 

Diff for: ‎server.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ def announce():
3535
if ip in app.config["BANLIST"]:
3636
return "Banned.", 403
3737

38-
if request.method == "POST":
39-
data = request.form["json"]
40-
else:
41-
data = request.args["json"]
38+
data = request.form["json"] if request.method == "POST" else request.args["json"]
4239

4340
if len(data) > 5000:
4441
return "JSON data is too big.", 413
@@ -90,18 +87,12 @@ def announce():
9087

9188
server["update_time"] = time.time()
9289

93-
if server["action"] == "start":
94-
server["start"] = time.time()
95-
else:
96-
server["start"] = old["start"]
90+
server["start"] = time.time() if server["action"] == "start" else old["start"]
9791

9892
if "clients_list" in server:
9993
server["clients"] = len(server["clients_list"])
10094

101-
if old:
102-
server["clients_top"] = max(server["clients"], old["clients_top"])
103-
else:
104-
server["clients_top"] = server["clients"]
95+
server["clients_top"] = max(server["clients"], old["clients_top"]) if old else server["clients"]
10596

10697
# Make sure that startup options are saved
10798
if server["action"] != "start":

0 commit comments

Comments
 (0)
Please sign in to comment.