From e8038bb9b54d1c9b1bb9d0d4223d26eaf6b8e4a0 Mon Sep 17 00:00:00 2001 From: al_headstrong Date: Wed, 11 Nov 2020 07:11:05 -0800 Subject: [PATCH] Updated per guided activity --- cgi-bin/cgi_2.py | 11 ++++++----- cgi-bin/cgi_sums.py | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cgi-bin/cgi_2.py b/cgi-bin/cgi_2.py index ae4ed0d..37fca4f 100644 --- a/cgi-bin/cgi_2.py +++ b/cgi-bin/cgi_2.py @@ -8,6 +8,7 @@ default = "No Value Present" +now = datetime.datetime.now() print("Content-Type: text/html") print("") @@ -23,10 +24,10 @@ """.format( software=os.environ.get('SERVER_SOFTWARE', default), - script='aaaa', - month='bbbb', - date='cccc', - year='dddd', - client_ip='eeee' + script=os.environ.get('SCRIPT_NAME', default), + month=now.strftime('%B'), + date=now.day, + year=now.year, + client_ip=os.environ.get('REMOTE_ADDR', default) ) print(body) diff --git a/cgi-bin/cgi_sums.py b/cgi-bin/cgi_sums.py index feed2bc..e070459 100644 --- a/cgi-bin/cgi_sums.py +++ b/cgi-bin/cgi_sums.py @@ -6,4 +6,8 @@ print("Content-type: text/plain") print() -print("Your job is to make this work") + +form = cgi.FieldStorage() +inputs = form.getlist('operand') + +print("The sum is : {}".format(sum(int(i) for i in inputs)))