Skip to content

Commit

Permalink
Use ternary operator when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul authored and sfan5 committed Jul 18, 2015
1 parent c26c42b commit 2fdd0da
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions server.py
Expand Up @@ -35,10 +35,7 @@ def announce():
if ip in app.config["BANLIST"]:
return "Banned.", 403

if request.method == "POST":
data = request.form["json"]
else:
data = request.args["json"]
data = request.form["json"] if request.method == "POST" else request.args["json"]

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

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

if server["action"] == "start":
server["start"] = time.time()
else:
server["start"] = old["start"]
server["start"] = time.time() if server["action"] == "start" else old["start"]

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

if old:
server["clients_top"] = max(server["clients"], old["clients_top"])
else:
server["clients_top"] = server["clients"]
server["clients_top"] = max(server["clients"], old["clients_top"]) if old else server["clients"]

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

0 comments on commit 2fdd0da

Please sign in to comment.