From a67a3e48bc9e0d3df5cc6108a6a470bd5dcb24c3 Mon Sep 17 00:00:00 2001
From: Michele Carignani <michele.carignani@etsi.org>
Date: Thu, 7 Mar 2019 11:15:07 +0100
Subject: [PATCH] extracted template and added a bit of style

---
 templates/home.html | 51 +++++++++++++++++++++++++++++++++++++++++++++
 web_app.py          | 17 ++-------------
 2 files changed, 53 insertions(+), 15 deletions(-)
 create mode 100644 templates/home.html

diff --git a/templates/home.html b/templates/home.html
new file mode 100644
index 0000000..f3aa261
--- /dev/null
+++ b/templates/home.html
@@ -0,0 +1,51 @@
+<!doctype html>
+
+<html>
+
+<head>
+<title>tosca2doc</title>
+<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
+
+</head>
+<body>
+
+<div class="container-fluid">
+
+{% with messages = get_flashed_messages() %}
+  {% if messages %}
+   <div class="alert alert-warning" role="alert">
+    <ul class=flashes>
+    {% for message in messages %}
+      <li>{{ message }}</li>
+    {% endfor %}
+    </ul>
+   </div>
+  {% endif %}
+{% endwith %}
+
+
+<h1 style="text-align:center">TOSCA export</h1>
+<div class="row">
+	<div class="col-sm">
+		<h2>tosca2doc</h2>
+		<form action="/tosca2doc" method="post" enctype="multipart/form-data">
+			Tosca YAML files:<br />
+			<input type="file" name="file" multiple=""/><br />
+			<input type="submit" value="Upload" />
+		</form>
+	</div>
+
+	<div class="col-sm">
+		<h2>doc2tosca</h2>
+			<form action="/doc2tosca" method="post" enctype="multipart/form-data">
+			Docx file:<br />
+			<input type="file" name="file" /><br />
+			<input type="submit" value="Upload" />
+		</form>
+	</div>
+</div>
+
+</div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/web_app.py b/web_app.py
index 203790b..e6593d3 100644
--- a/web_app.py
+++ b/web_app.py
@@ -2,7 +2,7 @@
 
 import os
 
-from flask import Flask, flash, request, redirect, url_for, send_file
+from flask import Flask, flash, request, redirect, url_for, send_file, render_template
 from werkzeug.utils import secure_filename
 import docx
 
@@ -18,19 +18,6 @@ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
 app.secret_key = 'super secret key'
 app.config['SESSION_TYPE'] = 'filesystem'
 
-HOME='''
-<!doctype html>
-<title>tosca2doc</title>
-<h1>tosca2doc & doc2tosca</h1>
-<h2>tosca2doc</h2>
-<form action="/tosca2doc" method="post" enctype="multipart/form-data">
-Tosca YAML file:
-<input type="file" name="file" multiple=""/>
-<input type="submit" value="Upload" />
-</form>
-<h2>doc2tosca</h2>
-'''
-
 TOSCA_DEFS=['VNFD', 'NSD', 'PNFD']
 
 def allowed_file(filename):
@@ -43,7 +30,7 @@ def allowed_file(filename):
 
 @app.route("/")
 def hello():
-    return HOME 
+    return render_template("./home.html") 
 
 @app.route("/tosca2doc", methods=['POST'])
 def mk_tosca2doc():
-- 
GitLab