Survey banner
The Dataiku Community is moving to a new home! Some short term disruption starting next week: LEARN MORE

Create a WebApp which returns some result via Python

Level 1
Create a WebApp which returns some result via Python


I trying to create a web app in which I can enter data via some form. The data should be processed via some Python snippet. But so far it is not working. Can somebody explain to me what I am doing wrong.

Attached my code and part of the error message.



<link rel="stylesheet" href="/static/public/styles/1.0.0/dku-styles.css" />

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Einfache Webanwendung</title>
    <h1>Einfache Webanwendung</h1>
    <form id="calcForm">
        <label for="number">Geben Sie eine Zahl ein:</label>
        <input type="number" id="number" name="number" required><br><br>
        <button type="submit" id="submit">Berechnen</button>
    <div id="resultDiv"></div>





document.addEventListener('DOMContentLoaded', function () {
    const form = document.getElementById('calcForm');
    const resultDiv = document.getElementById('resultDiv');

    form.addEventListener('submit', function (e) {
        const number = parseFloat(document.getElementById('number').value);
        const test = await fetch(getWebAppBackendUrl('/calculate'), {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                body: JSON.stringify({number}),
        document.getElementById("resultDiv").innerHTML = test;         





import dataiku
import pandas as pd

from flask import Flask, render_template, request, jsonify
import json  # Import the json module

def calculate():
    test = request.args
    return json.dumps({"status" : "ok" , "num" : test})



Part of my error message is:


"message":"Required request parameter \u0027projectKey\u0027 for method parameter type String is not present"


Operating system used: Linux

0 Kudos
1 Reply

There is a good example on how to use HTML Apps to retrieve a Dataset in the Knowledge site. I suggest you start with copying that, get it working and modify it after that:

Also there is this example on the Developer site:


0 Kudos