From 428ef48bed19a1f1b69021ccad3abc558d9c3322 Mon Sep 17 00:00:00 2001 From: Olivier Date: Wed, 28 Mar 2018 16:10:12 +0200 Subject: [PATCH 01/19] Flask 0.1 --- web_flask_OT.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 web_flask_OT.py diff --git a/web_flask_OT.py b/web_flask_OT.py new file mode 100644 index 0000000..0142736 --- /dev/null +++ b/web_flask_OT.py @@ -0,0 +1,10 @@ +from flask import Flask + +app = Flask(__name__) + +@app.route('/') +def index(): + return '

Hello World!

' + +if __name__ == '__main__': + app.run(debug = True) From 0a0bf29ecbd3b9a7fb584258c3a21532de8024ab Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Mar 2018 09:58:56 +0200 Subject: [PATCH 02/19] Flask 0.2 --- web_flask_OT.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web_flask_OT.py b/web_flask_OT.py index 0142736..10514be 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -8,3 +8,6 @@ def index(): if __name__ == '__main__': app.run(debug = True) + + +######################################################################################################################## From be37ee46c1182fd8996819bb5b50c0d8d52c8f49 Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Mar 2018 10:33:49 +0200 Subject: [PATCH 03/19] Flask 0.3 --- web_flask_OT.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index 10514be..87c7f19 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -7,7 +7,8 @@ def index(): return '

Hello World!

' if __name__ == '__main__': - app.run(debug = True) + app.run(host='0.0.0.0',debug = True) + ######################################################################################################################## From 235dbf6e10f857fd0a762a37be9c313256ee51d9 Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Mar 2018 11:33:06 +0200 Subject: [PATCH 04/19] Pseudo code Automatic web server 1.0 --- Automatic_web_flask_OT.py | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Automatic_web_flask_OT.py diff --git a/Automatic_web_flask_OT.py b/Automatic_web_flask_OT.py new file mode 100644 index 0000000..824288a --- /dev/null +++ b/Automatic_web_flask_OT.py @@ -0,0 +1,51 @@ +import subprocess +import os + +#connection à distance au serveur +subprocess.call("ssh-keygen -t rsa") +subprocess.call("ssh-copy-id bibi@") +subprocess.call("ssh bibi@") +subprocess.call('bibi_mdp') + +#installation diverses +subprocess.call('yum -y install net-tools') +subprocess.call('yum -y update') +if os.popen('rpm -qa kernel |sort -V |tail -n 1').read() != os.popen('uname -r').read(): os.popen('reboot') +subprocess.call("sudo yum -y install lsof") +subprocess.call("sudo yum -y install elinks") + +#installation de git +subprocess.call('sudo yum -y install git') + +print(os.popen("git --version").read()) + + +#git clone +subprocess.call("git clone git clone https://github.com/rvm8h/python-exercice.git") +subprocess.call("cd /python-exercice") +subprocess.call("git checkout branch -b Olivier") + +#installation de python +subprocess.call("sudo yum -y install yum-utils") +subprocess.call("sudo yum -y groupinstall development") +subprocess.call("sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm") +subprocess.call("sudo yum -y install python36u") +print(subprocess.call("python3.6 -V")) + + +#installation de pip +subprocess.call("sudo yum -y install python36u-pip") + +#installation de flask +subprocess.call("sudo pip3.6 install flask") + +#ouverture du firewall +subprocess.call("sudo firewall-cmd --zone=public --add-port=/tcp") + +#lancement du serveur +subprocess.call("python3.6 web_flask_OT runserver") +print(subprocess.call("lsof -i :")) +subprocess.call("elinks :") + + + From b539bf68011d39c7c8b9b0fc355a4240d2f60310 Mon Sep 17 00:00:00 2001 From: Olivier Date: Thu, 29 Mar 2018 11:50:14 +0200 Subject: [PATCH 05/19] Pseudo code Automatic web server 1.1 --- Automatic_web_flask_OT.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Automatic_web_flask_OT.py b/Automatic_web_flask_OT.py index 824288a..1def827 100644 --- a/Automatic_web_flask_OT.py +++ b/Automatic_web_flask_OT.py @@ -8,14 +8,15 @@ subprocess.call('bibi_mdp') #installation diverses -subprocess.call('yum -y install net-tools') -subprocess.call('yum -y update') +subprocess.call(['yum', '-y', 'install net-tools']) +subprocess.call(['yum', '-y', 'update']) + if os.popen('rpm -qa kernel |sort -V |tail -n 1').read() != os.popen('uname -r').read(): os.popen('reboot') -subprocess.call("sudo yum -y install lsof") -subprocess.call("sudo yum -y install elinks") +subprocess.call(["sudo yum", "-y", "install lsof"]) +subprocess.call(["sudo yum", "-y", "install elinks"]) #installation de git -subprocess.call('sudo yum -y install git') +subprocess.call(['sudo yum', '-y', 'install git']) print(os.popen("git --version").read()) From a85eb1cc605567f5487f54afeb26e4aabd855a43 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 09:52:49 +0200 Subject: [PATCH 06/19] ajout de commentaire web_flask --- web_flask_OT.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_flask_OT.py b/web_flask_OT.py index 87c7f19..cefc912 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -2,6 +2,7 @@ app = Flask(__name__) +#decorator @app.route('/') def index(): return '

Hello World!

' From 5da64eed3dfeaf6c5a934f61a377586ab25c5c7d Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:12:02 +0200 Subject: [PATCH 07/19] ajout de commentaire web_flask --- web_flask_OT.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web_flask_OT.py b/web_flask_OT.py index cefc912..58bd171 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -7,6 +7,13 @@ def index(): return '

Hello World!

' + +@app.route('user/') +def user(name): + return '

Hello {} !

'.format(name) + + + if __name__ == '__main__': app.run(host='0.0.0.0',debug = True) From 67108a0959f5ef1aebd503f95cb58608ed6d305d Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:15:43 +0200 Subject: [PATCH 08/19] ajout de code web_flask --- web_flask_OT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index 58bd171..3d56e97 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -8,7 +8,7 @@ def index(): return '

Hello World!

' -@app.route('user/') +@app.route('/user/') def user(name): return '

Hello {} !

'.format(name) From 6534bdd4eb8c758999f1473631124b99ed0f0701 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:27:44 +0200 Subject: [PATCH 09/19] ajout de code web_flask 1.5 --- web_flask_OT.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index 3d56e97..7adf5c9 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -1,18 +1,23 @@ from flask import Flask +from flask import request +from flask import redirect app = Flask(__name__) #decorator @app.route('/') def index(): - return '

Hello World!

' + user_agent = request.headers.get('User-Agent') + return '

Hello World!

\n

Your Browser is {}

'.format(user_agent) @app.route('/user/') def user(name): return '

Hello {} !

'.format(name) - +@app.route('/site') +def redir(): + return redirect('https://www.python.org/') if __name__ == '__main__': app.run(host='0.0.0.0',debug = True) From 35097e5a19f1f5849778d4f6880960cb11127215 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:32:25 +0200 Subject: [PATCH 10/19] =?UTF-8?q?cr=C3=A9ation=20Index.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Templates/Index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Templates/Index.html diff --git a/Templates/Index.html b/Templates/Index.html new file mode 100644 index 0000000..8167b75 --- /dev/null +++ b/Templates/Index.html @@ -0,0 +1,10 @@ + + + + + test {{ name }} + + + + + \ No newline at end of file From d10f596b7ea15c5cc217faac88a6a3612ccbfc47 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:34:48 +0200 Subject: [PATCH 11/19] Ajout de l'Index dans web_flask --- web_flask_OT.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index 7adf5c9..d06a61c 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -1,6 +1,7 @@ from flask import Flask from flask import request -from flask import redirect +from flask import redirect, render_template + app = Flask(__name__) @@ -13,7 +14,7 @@ def index(): @app.route('/user/') def user(name): - return '

Hello {} !

'.format(name) + return render_template('Index.html', name = name) @app.route('/site') def redir(): From 9df80d62398d08ff7d3d972fde8ddc8c243b3e58 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:36:38 +0200 Subject: [PATCH 12/19] Ajout de l'Index dans web_flask --- web_flask_OT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index d06a61c..9de3e3a 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -14,7 +14,7 @@ def index(): @app.route('/user/') def user(name): - return render_template('Index.html', name = name) + return render_template('Index.html', name = 'Templates') @app.route('/site') def redir(): From d7da1f006fea6952ea28694850e7b3257589ff7a Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:39:19 +0200 Subject: [PATCH 13/19] Ajout de l'Index dans web_flask --- Templates/Index.html | 10 ---------- template/index.html | 1 + web_flask_OT.py | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 Templates/Index.html create mode 100644 template/index.html diff --git a/Templates/Index.html b/Templates/Index.html deleted file mode 100644 index 8167b75..0000000 --- a/Templates/Index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - test {{ name }} - - - - - \ No newline at end of file diff --git a/template/index.html b/template/index.html new file mode 100644 index 0000000..3f461ad --- /dev/null +++ b/template/index.html @@ -0,0 +1 @@ +

Hello! {{ name }}

\ No newline at end of file diff --git a/web_flask_OT.py b/web_flask_OT.py index 9de3e3a..d06a61c 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -14,7 +14,7 @@ def index(): @app.route('/user/') def user(name): - return render_template('Index.html', name = 'Templates') + return render_template('Index.html', name = name) @app.route('/site') def redir(): From 9759d47215da3b7d209220624ea68c49f6653466 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:39:50 +0200 Subject: [PATCH 14/19] Ajout de l'Index dans web_flask --- {template => templates}/index.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {template => templates}/index.html (100%) diff --git a/template/index.html b/templates/index.html similarity index 100% rename from template/index.html rename to templates/index.html From c99669f8a1689168fe4c6e63d2bf744a6e7479ab Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:41:19 +0200 Subject: [PATCH 15/19] Ajout de l'Index dans web_flask 2.0 --- web_flask_OT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index d06a61c..244ee27 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -14,7 +14,7 @@ def index(): @app.route('/user/') def user(name): - return render_template('Index.html', name = name) + return render_template('index.html', name = name) @app.route('/site') def redir(): From 49f9336d3c614c25d6ac207c829c403461e709d5 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:50:58 +0200 Subject: [PATCH 16/19] Ajout de l'Index dans web_flask --- templates/404.html | 1 + templates/index.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 templates/404.html diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..e5a9fdb --- /dev/null +++ b/templates/404.html @@ -0,0 +1 @@ +

404 page not found

\ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 3f461ad..388dd82 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1 +1 @@ -

Hello! {{ name }}

\ No newline at end of file +

Hello {{ name }}!

\ No newline at end of file From 3b5097bf649f74902502c47d2bec6caea1073d75 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:52:55 +0200 Subject: [PATCH 17/19] Ajout de l'Index dans web_flask --- web_flask_OT.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web_flask_OT.py b/web_flask_OT.py index 244ee27..ea79299 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -16,6 +16,10 @@ def index(): def user(name): return render_template('index.html', name = name) +@app.errohandler(404) +def page_not_found(e): + return render_template('404.html'),404 + @app.route('/site') def redir(): return redirect('https://www.python.org/') From c72d6b1c752381dfd9ed5bd3ebd89b1ba9a259ea Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:53:55 +0200 Subject: [PATCH 18/19] Ajout de l'error handler dans web_flask --- web_flask_OT.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_flask_OT.py b/web_flask_OT.py index ea79299..9b997e4 100644 --- a/web_flask_OT.py +++ b/web_flask_OT.py @@ -16,7 +16,7 @@ def index(): def user(name): return render_template('index.html', name = name) -@app.errohandler(404) +@app.errorhandler(404) def page_not_found(e): return render_template('404.html'),404 From e058a86a10fd3e6bd5986bd0e2f3132e2fd51d99 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 30 Mar 2018 11:55:15 +0200 Subject: [PATCH 19/19] maj de 404.html --- templates/404.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/404.html b/templates/404.html index e5a9fdb..d870279 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1 +1 @@ -

404 page not found

\ No newline at end of file +

Error 404 page not found

\ No newline at end of file