From e0222d30a5200f4c2d39805caf41bb5d6d7a1213 Mon Sep 17 00:00:00 2001 From: Harissa Date: Tue, 5 Oct 2021 10:10:44 +0100 Subject: [PATCH 01/16] Update server.py Test text change and server update --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 430d1dc7..194446f0 100644 --- a/server.py +++ b/server.py @@ -9,7 +9,7 @@ class Handler(http.server.SimpleHTTPRequestHandler): def do_GET(self): self.send_response(HTTPStatus.OK) self.end_headers() - msg = 'Hello! you requested %s' % (self.path) + msg = 'Hello, FISH ! you requested %s' % (self.path) self.wfile.write(msg.encode()) From fa28fdb862511346c945a014c921b66add542285 Mon Sep 17 00:00:00 2001 From: Harissa Date: Tue, 5 Oct 2021 10:25:43 +0100 Subject: [PATCH 02/16] Create test.html Added test.html --- test.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.html diff --git a/test.html b/test.html new file mode 100644 index 00000000..88e01765 --- /dev/null +++ b/test.html @@ -0,0 +1 @@ + Test static html From 2fbc51475612b7ca17f2c02dea9e461d8a2a7792 Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 11:32:04 +0100 Subject: [PATCH 03/16] Create test.html Added html test in folder --- static/test.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 static/test.html diff --git a/static/test.html b/static/test.html new file mode 100644 index 00000000..f8cd0c84 --- /dev/null +++ b/static/test.html @@ -0,0 +1 @@ + Testing testing 1 2 3 From abf7b90d5bcf239b018fa874f0cf85cbed41e4c0 Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 11:41:39 +0100 Subject: [PATCH 04/16] Create index.html Add index file --- static/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 static/index.html diff --git a/static/index.html b/static/index.html new file mode 100644 index 00000000..1e107669 --- /dev/null +++ b/static/index.html @@ -0,0 +1 @@ + This is the index file From e0c6f9646304c6cd56222ac924ce7690b6b8a181 Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:19:42 +0100 Subject: [PATCH 05/16] Update server.py Added test file read code --- server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.py b/server.py index 194446f0..94aec067 100644 --- a/server.py +++ b/server.py @@ -10,6 +10,8 @@ def do_GET(self): self.send_response(HTTPStatus.OK) self.end_headers() msg = 'Hello, FISH ! you requested %s' % (self.path) + f = open("demofile.txt", "r") + msg = f.read(); self.wfile.write(msg.encode()) From d70e9dbda99e73643874a3d6ec7b50ede8bf482a Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:20:47 +0100 Subject: [PATCH 06/16] Create demofile.text Add demo file read --- demofile.text | 1 + 1 file changed, 1 insertion(+) create mode 100644 demofile.text diff --git a/demofile.text b/demofile.text new file mode 100644 index 00000000..8410348b --- /dev/null +++ b/demofile.text @@ -0,0 +1 @@ +This is a demo file read From 72aec0dfabf0d55a9b439f9a419deeddc11d4c71 Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:29:04 +0100 Subject: [PATCH 07/16] Create demofile2 Added demo file to static folder --- static/demofile2 | 1 + 1 file changed, 1 insertion(+) create mode 100644 static/demofile2 diff --git a/static/demofile2 b/static/demofile2 new file mode 100644 index 00000000..3a451c55 --- /dev/null +++ b/static/demofile2 @@ -0,0 +1 @@ +This is demo reading file2 From 61c1fd9254bb994587e2c41b00aafc865fce2f34 Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:29:48 +0100 Subject: [PATCH 08/16] Rename demofile2 to demofile2.txt changed to .txt extension --- static/{demofile2 => demofile2.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename static/{demofile2 => demofile2.txt} (100%) diff --git a/static/demofile2 b/static/demofile2.txt similarity index 100% rename from static/demofile2 rename to static/demofile2.txt From 3488cff8d66539269a62923420c8484151e22e5e Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:38:58 +0100 Subject: [PATCH 09/16] Update server.py Change file path --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index 94aec067..61df3211 100644 --- a/server.py +++ b/server.py @@ -10,7 +10,7 @@ def do_GET(self): self.send_response(HTTPStatus.OK) self.end_headers() msg = 'Hello, FISH ! you requested %s' % (self.path) - f = open("demofile.txt", "r") + f = open("/static/demofile2.txt", "r") msg = f.read(); self.wfile.write(msg.encode()) From 3e2bf88e319f87e83544bdbad2aa38667cc9638c Mon Sep 17 00:00:00 2001 From: Harissa Date: Wed, 6 Oct 2021 13:55:12 +0100 Subject: [PATCH 10/16] Update server.py edit file path --- server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 61df3211..d62bdc9f 100644 --- a/server.py +++ b/server.py @@ -10,8 +10,8 @@ def do_GET(self): self.send_response(HTTPStatus.OK) self.end_headers() msg = 'Hello, FISH ! you requested %s' % (self.path) - f = open("/static/demofile2.txt", "r") - msg = f.read(); + f = open("static/demofile2.txt", "r") + msg = f.read() self.wfile.write(msg.encode()) From 5e6597664c99d78f56db1cc1851a05adc7a2f16d Mon Sep 17 00:00:00 2001 From: Joe Cutting Date: Thu, 7 Oct 2021 10:12:37 +0100 Subject: [PATCH 11/16] try running flask --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..87e64a74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/TestEnvironment From 95c04cdbfd751c78559ee917dcfbe70c6e94e94e Mon Sep 17 00:00:00 2001 From: Joe Cutting Date: Thu, 7 Oct 2021 10:15:09 +0100 Subject: [PATCH 12/16] Try running flask --- .gitignore | 1 + Procfile | 2 +- app.py | 20 ++++++++++++++++++++ requirements.txt | 1 + server.py | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app.py diff --git a/.gitignore b/.gitignore index 87e64a74..2857c89e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ ################################################################################ /TestEnvironment +/.vs diff --git a/Procfile b/Procfile index ac9d762f..2e35818f 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: python server.py +web: python app.py diff --git a/app.py b/app.py new file mode 100644 index 00000000..f1c69338 --- /dev/null +++ b/app.py @@ -0,0 +1,20 @@ +from flask import Flask + +# Create an instance of the Flask class that is the WSGI application. +# The first argument is the name of the application module or package, +# typically __name__ when using a single module. +app = Flask(__name__) + +# Flask route decorators map / and /hello to the hello function. +# To add other resources, create functions that generate the page contents +# and add decorators to define the appropriate resource locators for them. + +@app.route('/') +@app.route('/hello') +def hello(): + # Render the page + return "Hello Python! flask is working" + +if __name__ == '__main__': + # Run the app server on localhost:4449 + app.run('localhost', 4449) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e69de29b..2db5aeaf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==2.0.2 \ No newline at end of file diff --git a/server.py b/server.py index d62bdc9f..107646bf 100644 --- a/server.py +++ b/server.py @@ -15,7 +15,7 @@ def do_GET(self): self.wfile.write(msg.encode()) -port = int(os.getenv('PORT', 80)) +port = int(os.getenv('PORT', 8080)) print('Listening on port %s' % (port)) httpd = socketserver.TCPServer(('', port), Handler) httpd.serve_forever() From 83b45b4a3e246a20a83b32b9a4b8db8e79c8acf4 Mon Sep 17 00:00:00 2001 From: Joe Cutting Date: Thu, 7 Oct 2021 10:30:18 +0100 Subject: [PATCH 13/16] test to see it always uses server.py --- Procfile | 2 +- app.py | 20 -------------------- oldServer.py | 21 +++++++++++++++++++++ server.py | 33 ++++++++++++++++----------------- 4 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 app.py create mode 100644 oldServer.py diff --git a/Procfile b/Procfile index 2e35818f..ac9d762f 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: python app.py +web: python server.py diff --git a/app.py b/app.py deleted file mode 100644 index f1c69338..00000000 --- a/app.py +++ /dev/null @@ -1,20 +0,0 @@ -from flask import Flask - -# Create an instance of the Flask class that is the WSGI application. -# The first argument is the name of the application module or package, -# typically __name__ when using a single module. -app = Flask(__name__) - -# Flask route decorators map / and /hello to the hello function. -# To add other resources, create functions that generate the page contents -# and add decorators to define the appropriate resource locators for them. - -@app.route('/') -@app.route('/hello') -def hello(): - # Render the page - return "Hello Python! flask is working" - -if __name__ == '__main__': - # Run the app server on localhost:4449 - app.run('localhost', 4449) \ No newline at end of file diff --git a/oldServer.py b/oldServer.py new file mode 100644 index 00000000..107646bf --- /dev/null +++ b/oldServer.py @@ -0,0 +1,21 @@ +import os +import http.server +import socketserver + +from http import HTTPStatus + + +class Handler(http.server.SimpleHTTPRequestHandler): + def do_GET(self): + self.send_response(HTTPStatus.OK) + self.end_headers() + msg = 'Hello, FISH ! you requested %s' % (self.path) + f = open("static/demofile2.txt", "r") + msg = f.read() + self.wfile.write(msg.encode()) + + +port = int(os.getenv('PORT', 8080)) +print('Listening on port %s' % (port)) +httpd = socketserver.TCPServer(('', port), Handler) +httpd.serve_forever() diff --git a/server.py b/server.py index 107646bf..f1c69338 100644 --- a/server.py +++ b/server.py @@ -1,21 +1,20 @@ -import os -import http.server -import socketserver +from flask import Flask -from http import HTTPStatus +# Create an instance of the Flask class that is the WSGI application. +# The first argument is the name of the application module or package, +# typically __name__ when using a single module. +app = Flask(__name__) +# Flask route decorators map / and /hello to the hello function. +# To add other resources, create functions that generate the page contents +# and add decorators to define the appropriate resource locators for them. -class Handler(http.server.SimpleHTTPRequestHandler): - def do_GET(self): - self.send_response(HTTPStatus.OK) - self.end_headers() - msg = 'Hello, FISH ! you requested %s' % (self.path) - f = open("static/demofile2.txt", "r") - msg = f.read() - self.wfile.write(msg.encode()) +@app.route('/') +@app.route('/hello') +def hello(): + # Render the page + return "Hello Python! flask is working" - -port = int(os.getenv('PORT', 8080)) -print('Listening on port %s' % (port)) -httpd = socketserver.TCPServer(('', port), Handler) -httpd.serve_forever() +if __name__ == '__main__': + # Run the app server on localhost:4449 + app.run('localhost', 4449) \ No newline at end of file From 418db6fcbe2ef69c3fbc01008a655169be5a3c1a Mon Sep 17 00:00:00 2001 From: Joe Cutting Date: Thu, 7 Oct 2021 10:52:32 +0100 Subject: [PATCH 14/16] Add waitress to code --- requirements.txt | 3 ++- server.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2db5aeaf..c2d81ef2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Flask==2.0.2 \ No newline at end of file +Flask==2.0.2 +Waitress==2.0.0 \ No newline at end of file diff --git a/server.py b/server.py index f1c69338..b50dd2a7 100644 --- a/server.py +++ b/server.py @@ -16,5 +16,7 @@ def hello(): return "Hello Python! flask is working" if __name__ == '__main__': - # Run the app server on localhost:4449 - app.run('localhost', 4449) \ No newline at end of file + from waitress import serve + serve(app, host="0.0.0.0", port=8080) + # Run the app server on localhost:4449 + # app.run('localhost', 4449) \ No newline at end of file From dbb0f14b41071c089015f6151c918a05a671a7c1 Mon Sep 17 00:00:00 2001 From: Harissa Date: Thu, 7 Oct 2021 10:57:06 +0100 Subject: [PATCH 15/16] Update server.py Tweak code to to rebuild --- server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index b50dd2a7..fed4942b 100644 --- a/server.py +++ b/server.py @@ -13,10 +13,10 @@ @app.route('/hello') def hello(): # Render the page - return "Hello Python! flask is working" + return "Hello Python! Waitress brings flask so its working" if __name__ == '__main__': from waitress import serve serve(app, host="0.0.0.0", port=8080) # Run the app server on localhost:4449 - # app.run('localhost', 4449) \ No newline at end of file + # app.run('localhost', 4449) From 766827ee7b36d5261a2f6cc5bb3108722c164f5b Mon Sep 17 00:00:00 2001 From: Harissa Date: Thu, 7 Oct 2021 13:11:00 +0100 Subject: [PATCH 16/16] Update server.py Nudge sample python repo --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index fed4942b..3b9ef7d9 100644 --- a/server.py +++ b/server.py @@ -13,7 +13,7 @@ @app.route('/hello') def hello(): # Render the page - return "Hello Python! Waitress brings flask so its working" + return "Hello Python! Sample Python Waitress brings flask so its working" if __name__ == '__main__': from waitress import serve