title: Flask, SAP UI5 and MVC
body: <p>I want to build a Python-Flask Application and use SAPUI5.
  I tried to build this small Application in Flask: <a href="https://sapui5.hana.ondemand.com/1.60.1/#/sample/sap.m.tutorial.walkthrough.05/preview" rel="nofollow noreferrer">https://sapui5.hana.ondemand.com/1.60.1/#/sample/sap.m.tutorial.walkthrough.05/preview</a></p>
  
  <p>Everything worked well and my code looks like this:</p>
  
  <p><strong>app.py</strong></p>
  
  <pre><code>from flask import Flask, render_template
  
  app = Flask(__name__)
  
  
  @app.route('/')
  def hello_world():
      return render_template("index.html")
  
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;SAPUI5 Walkthrough&lt;/title&gt;
      &lt;script
          id="sap-ui-bootstrap"
          src="/static/sap-ui-core.js"
          data-sap-ui-theme="sap_belize"
          data-sap-ui-libs="sap.m"
          data-sap-ui-compatVersion="edge"
          data-sap-ui-preload="async"
          data-sap-ui-resourceroots='{
              "static": "./"
          }'
          &gt;
      &lt;/script&gt;
      &lt;script&gt;
          sap.ui.getCore().attachInit(function () {
              sap.ui.xmlview({
                  viewName: "mvc.view.App"
              }).placeAt("content");
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body class="sapUiBody" id="content"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>App.view.xml</strong></p>
  
  <pre><code>&lt;mvc:View
      controllerName="mvc.controller.App"
      xmlns="sap.m"
      xmlns:mvc="sap.ui.core.mvc"&gt;
      &lt;Button
          text="Say Hello"
          press="onShowHello"/&gt;
  &lt;/mvc:View&gt;
  </code></pre>
  
  <p><strong>App.controller.js</strong></p>
  
  <pre><code>sap.ui.define([
      "sap/ui/core/mvc/Controller"
  ], function (Controller) {
      "use strict";
  
      return Controller.extend("mvc.App", {
  
          onShowHello : function () {
              // show a native JavaScript alert
              /* eslint-disable no-alert */
              alert("Hello World");
              /* eslint-enable no-alert */
          }
      });
  
  });
  </code></pre>
  
  <p><strong>My question now is</strong>: How can I pass parameters from my app.py to the App.view.xml and App.controller.js? </p>
  
  <p>At the end I want to achieve something like this:</p>
  
  <p><strong>app.py</strong></p>
  
  <pre><code>from flask import Flask, render_template
  
  app = Flask(__name__)
  
  
  @app.route('/')
  def hello_world():
      return render_template("index.html", text="Hello World", buttonlabel="Say Hello")
  
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p><strong>App.view.xml</strong></p>
  
  <pre><code>&lt;mvc:View
      controllerName="mvc.controller.App"
      xmlns="sap.m"
      xmlns:mvc="sap.ui.core.mvc"&gt;
      &lt;Button
          text="{{ buttonlabel }}"
          press="onShowHello"/&gt;
  &lt;/mvc:View&gt;
  </code></pre>
  
  <p><strong>App.controller.js</strong></p>
  
  <pre><code>sap.ui.define([
      "sap/ui/core/mvc/Controller"
  ], function (Controller) {
      "use strict";
  
      return Controller.extend("mvc.App", {
  
          onShowHello : function () {
              // show a native JavaScript alert
              /* eslint-disable no-alert */
              alert({{ text }});
              /* eslint-enable no-alert */
          }
      });
  
  });
  </code></pre>