Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
stdout write for server port and remove redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
dcdenu4 committed Dec 4, 2020
1 parent 2035fa1 commit 4c398b9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import pprint
import socket
import sys
import textwrap

from flask import Flask
Expand Down Expand Up @@ -220,8 +221,10 @@ def save_to_python():
parser.add_argument(
"--flex", default=True, help="The port number of the Flask Server.")
args = vars(parser.parse_args())
port = int(args.get('port', 5000))
flex = bool(args.get('flex', True))
# Since port and flex are optional arguments with defaults, they should
# always be keys
port = int(args['port'])
flex = bool(args['flex'])

port_good = False
# Number of ports to increment for attempts
Expand All @@ -244,6 +247,6 @@ def save_to_python():
port = port + 1

# Write to stdout so that parent process can receive the used port number
print(f'PORT {port}')
app.run(port=int(port))
sys.stdout.write(f'PORT {port}')
app.run(port=port)

0 comments on commit 4c398b9

Please sign in to comment.