diff --git a/Automatic_web_flask_OT.py b/Automatic_web_flask_OT.py new file mode 100644 index 0000000..1def827 --- /dev/null +++ b/Automatic_web_flask_OT.py @@ -0,0 +1,52 @@ +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 :") + + + diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..d870279 --- /dev/null +++ b/templates/404.html @@ -0,0 +1 @@ +

Error 404 page not found

\ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..388dd82 --- /dev/null +++ b/templates/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 new file mode 100644 index 0000000..9b997e4 --- /dev/null +++ b/web_flask_OT.py @@ -0,0 +1,32 @@ +from flask import Flask +from flask import request +from flask import redirect, render_template + + +app = Flask(__name__) + +#decorator +@app.route('/') +def index(): + user_agent = request.headers.get('User-Agent') + return '

Hello World!

\n

Your Browser is {}

'.format(user_agent) + + +@app.route('/user/') +def user(name): + return render_template('index.html', name = name) + +@app.errorhandler(404) +def page_not_found(e): + return render_template('404.html'),404 + +@app.route('/site') +def redir(): + return redirect('https://www.python.org/') + +if __name__ == '__main__': + app.run(host='0.0.0.0',debug = True) + + + +########################################################################################################################