Skip to content

Commit

Permalink
Modify render function to use context manager for file opening
Browse files Browse the repository at this point in the history
  • Loading branch information
letroot committed Jun 6, 2016
1 parent 34ac4d4 commit c1576c3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chapeau.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ def post(clientsocket, request):

# ----- sends http msg and page to client socket, then closes socket -----
def render(clientsocket, path, params, header = None):
message_file = open(path, 'r')
message_text = message_file.read()
message_file.close()
with open(path, 'r') as message_file:
message_text = message_file.read()
new_msg = message_text % params
header_string = ''
if header != None:
Expand Down

0 comments on commit c1576c3

Please sign in to comment.