p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] index.html (html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Stockwerkskasse</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <div class="jumbotron">
    <h1 id="welcome"></h1>
    <h2 id="balance"></h2>
    <br/>
    <p id="beers"></p>
    <p id="coffees"></p>
    <br/>
    <a href="upload_bill.html" >Upload Bill</a> 
    <script type="text/javascript" src="index.js"></script> 

  </div>
</div>

</body>
</html>
[tab] login.html (html)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Stockwerkskasse</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <div class="jumbotron">
    <h1>Please login for Stockwerkskasse</h1>
    <form>
    <label for="fname">First name:</label><br>
    <input type="text" id="fname" name="fname"><br>
    <label for="pwd">Password:</label><br>
    <input type="password" id="pwd" name="pwd">
    </form> 
    </div>
</div>

</body>
</html>
[content] index.html (html)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Dorm Expenses</title>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex flex-col items-center justify-center min-h-screen p-4">
  <div class="w-full max-w-sm bg-white shadow-md rounded-2xl p-6">
    <h1 class="text-2xl font-bold mb-6 text-center">Dorm Expenses</h1>

    <!-- Before login -->
    <div id="login-section" class="text-center">
      <button 
        id="login-btn" 
        class="w-full py-3 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition">
        Sign in with Cognito
      </button>
    </div>

    <!-- After login -->
    <div id="user-section" class="hidden text-center">
      <p class="text-lg mb-4">Hello <span id="username"></span> 👋</p>
      <button 
        id="logout-btn" 
        class="w-full py-3 bg-red-500 text-white rounded-xl hover:bg-red-600 transition">
        Sign out
      </button>
    </div>
  </div>

  <script>
    // Replace these with your Cognito settings
    const COGNITO_DOMAIN = "https://YOUR-COGNITO-DOMAIN.auth.YOUR-REGION.amazoncognito.com";
    const CLIENT_ID = "YOUR_CLIENT_ID";
    const REDIRECT_URI = "https://YOUR-CLOUDFRONT-URL"; // or localhost for testing

    // Parse query params for code/token
    function getQueryParam(param) {
      const urlParams = new URLSearchParams(window.location.search);
      return urlParams.get(param);
    }

    // Show login or user section
    function showUser(username) {
      document.getElementById("login-section").classList.add("hidden");
      document.getElementById("user-section").classList.remove("hidden");
      document.getElementById("username").textContent = username;
    }

    function showLogin() {
      document.getElementById("login-section").classList.remove("hidden");
      document.getElementById("user-section").classList.add("hidden");
    }

    // Handle login
    document.getElementById("login-btn").addEventListener("click", () => {
      window.location.href = `${
[content] index.html (html)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Dorm Expenses</title>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex flex-col items-center justify-center min-h-screen p-4">
  <div class="w-full max-w-sm bg-white shadow-md rounded-2xl p-6">
    <h1 class="text-2xl font-bold mb-6 text-center">Dorm Expenses</h1>

    <!-- Before login -->
    <div id="login-section" class="text-center">
      <button 
        id="login-btn" 
        class="w-full py-3 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition">
        Sign in with Cognito
      </button>
    </div>

    <!-- After login -->
    <div id="user-section" class="hidden text-center">
      <p class="text-lg mb-4">Hello <span id="username"></span> 👋</p>
      <button 
        id="logout-btn" 
        class="w-full py-3 bg-red-500 text-white rounded-xl hover:bg-red-600 transition">
        Sign out
      </button>
    </div>
  </div>

  <script>
    // Replace these with your Cognito settings
    const COGNITO_DOMAIN = "https://YOUR-COGNITO-DOMAIN.auth.YOUR-REGION.amazoncognito.com";
    const CLIENT_ID = "YOUR_CLIENT_ID";
    const REDIRECT_URI = "https://YOUR-CLOUDFRONT-URL"; // or localhost for testing

    // Parse query params for code/token
    function getQueryParam(param) {
      const urlParams = new URLSearchParams(window.location.search);
      return urlParams.get(param);
    }

    // Show login or user section
    function showUser(username) {
      document.getElementById("login-section").classList.add("hidden");
      document.getElementById("user-section").classList.remove("hidden");
      document.getElementById("username").textContent = username;
    }

    function showLogin() {
      document.getElementById("login-section").classList.remove("hidden");
      document.getElementById("user-section").classList.add("hidden");
    }

    // Handle login
    document.getElementById("login-btn").addEventListener("click", () => {
      window.location.href = `${COGNITO_DOMAIN}/login?client_id=${CLIENT_ID}&response_type=token&scope=openid+profile+email&redirect_uri=${REDIRECT_URI}`;
    });

    // Handle logout
    document.getElementById("logout-btn").addEventListener("click", () => {
      window.location.href = `${COGNITO_DOMAIN}/logout?client_id=${CLIENT_ID}&logout_uri=${REDIRECT_URI}`;
    });

    // On load: check if we have token
    const hash = window.location.hash.substr(1);
    const params = new URLSearchParams(hash);
    const idToken = params.get("id_token");

    if (idToken) {
      // Decode token (basic parse, not secure validation)
      const payload = JSON.parse(atob(idToken.split('.')[1]));
      showUser(payload["email"]);
    } else {
      showLogin();
    }
  </script>
</body>
</html>
[tab] index.html_bak (plaintext)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Dorm Expenses</title>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 flex flex-col items-center justify-center min-h-screen p-4">
  <div class="w-full max-w-sm bg-white shadow-md rounded-2xl p-6">
    <h1 class="text-2xl font-bold mb-6 text-center">Dorm Expenses</h1>

    <!-- Before login -->
    <div id="login-section" class="text-center">
      <button 
        id="login-btn" 
        class="w-full py-3 bg-blue-600 text-white rounded-xl hover:bg-blue-700 transition">
        Sign in with Cognito
      </button>
    </div>

    <!-- After login -->
    <div id="user-section" class="hidden text-center">
      <p class="text-lg mb-4">Hello <span id="username"></span> 👋</p>
      <button 
        id="logout-btn" 
        class="w-full py-3 bg-red-500 text-white rounded-xl hover:bg-red-600 transition">
        Sign out
      </button>
    </div>
  </div>

  <script>
    // Replace these with your Cognito settings
    const COGNITO_DOMAIN = "https://YOUR-COGNITO-DOMAIN.auth.YOUR-REGION.amazoncognito.com";
    const CLIENT_ID = "YOUR_CLIENT_ID";
    const REDIRECT_URI = "https://YOUR-CLOUDFRONT-URL"; // or localhost for testing

    // Parse query params for code/token
    function getQueryParam(param) {
      const urlParams = new URLSearchParams(window.location.search);
      return urlParams.get(param);
    }

    // Show login or user section
    function showUser(username) {
      document.getElementById("login-section").classList.add("hidden");
      document.getElementById("user-section").classList.remove("hidden");
      document.getElementById("username").textContent = username;
    }

    function showLogin() {
      document.getElementById("login-section").classList.remove("hidden");
      document.getElementById("user-section").classList.add("hidden");
    }

    // Handle login
    document.getElementById("login-btn").addEventListener("click", () => {
      window.location.href = `${COGNITO_DOMAIN}/login?client_id=${CLIENT_ID}&response_type=token&scope=openid+profile+email&redirect_uri=${REDIRECT_URI}`;
    });

    // Handle logout
    document.getElementById("logout-btn").addEventListener("click", () => {
      window.location.href = `${COGNITO_DOMAIN}/logout?client_id=${CLIENT_ID}&logout_uri=${REDIRECT_URI}`;
    });

    // On load: check if we have token
    const hash = window.location.hash.substr(1);
    const params = new URLSearchParams(hash);
    const idToken = params.get("id_token");

    if (idToken) {
      // Decode token (basic parse, not secure validation)
      const payload = JSON.parse(atob(idToken.split('.')[1]));
      showUser(payload["email"]);
    } else {
      showLogin();
    }
  </script>
</body>
</html>
[content] lamda_function.py (python)
import json
from decimal import Decimal

# For now, we'll use a simple in-memory stub database
# Later, replace with DynamoDB queries
STUB_USERS = {
    "alice@example.com": Decimal("12.50"),
    "bob@example.com": Decimal("7.30"),
    "charlie@example.com": Decimal("-5.20")
}

def lambda_handler(event, context):
    """
    Expects a GET request with an 'email' query parameter
    Returns the user's current balance
    """
    try:
        # Get email from query params
        email = event.get("queryStringParameters", {}).get("email")
        if not email:
            return {
                "statusCode": 400,
                "body": json.dumps({"error": "Missing email parameter"})
            }
        
        # Lookup balance (stub)
        balance = STUB_USERS.get(email, Decimal("0.00"))
        
        return {
            "statusCode": 200,
            "headers": {
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin": "*"  # allow your frontend to call
            },
            "body": json.dumps({"balance": float(balance)})
        }
        
    except Exception as e:
        return {
            "statusCode": 500,
            "body": json.dumps({"error": str(e)})
        }
[tab] lambda_function.py (python)
import json
from decimal import Decimal

# For now, we'll use a simple in-memory stub database
# Later, replace with DynamoDB queries
STUB_USERS = {
    "alice@example.com": Decimal("12.50"),
    "bob@example.com": Decimal("7.30"),
    "charlie@example.com": Decimal("-5.20"),
    "mihir.mahajan2002@gmail.com": Decimal("100.42")
}

def lambda_handler(event, context):
    """
    Expects a GET request with an 'email' query parameter
    Returns the user's current balance
    """
    try:
        # Get email from query params
        email = event.get("queryStringParameters", {}).get("email")
        if not email:
            return {
                "statusCode": 400,
                "body": json.dumps({"error": "Missing email parameter"})
            }
        
        # Lookup balance (stub)
        balance = STUB_USERS.get(email, Decimal("0.00"))
        
        return {
            "statusCode": 200,
            "headers": {
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin": "*"  # allow your frontend to call
            },
            "body": json.dumps({"balance": float(balance)})
        }
        
    except Exception as e:
        return {
            "statusCode": 500,
            "body": json.dumps({"error": str(e)})
        }
[content] index.html (html)
async function fetchBalance() {
  const balanceEl = document.getElementById("balance");
  balanceEl.textContent = "loading...";
  try {
    const idToken = localStorage.getItem("id_token");
    const payload = JSON.parse(atob(idToken.split(".")[1]));
    const email = payload["email"];

    // Replace with your actual API Gateway endpoint
    const apiUrl = "https://YOUR_API_GATEWAY_ID.execute-api.eu-central-1.amazonaws.com/balance";
    const res = await fetch(`${apiUrl}?email=${encodeURIComponent(email)}`, {
      method: "GET",
      headers: {
        "Authorization": `Bearer ${idToken}`  // optional, if you secure your API later
      }
    });
    const data = await res.json();
    balanceEl.textContent = data.balance.toFixed(2);
  } catch (err) {
    balanceEl.textContent = "error";
    console.error("Failed to fetch balance:", err);
  }
}
[content] index.html (html)
    23|    <div id="user-section" class="hidden flex flex-col h-[28rem] justify-between">
    24|      <div>
    25|        <h2 class="text-4xl font-extrabold text-center mb-2" id="greeting">Hello <span id="username"></span> 👋</h2>
    26|        <p class="text-center text-lg text-gray-500 mb-8 italic">Keeping your dorm expenses even, always!</p>
    27|        <div class="flex flex-col items-center mb-8">
    28|          <span class="text-md text-gray-500 mb-2">Your current balance</span>
    29|          <span id="balance" class="text-6xl font-bold transition-colors duration-300">loading...</span>
    30|          <span class="text-gray-400 text-sm mt-2">in Euros (€)</span>
    31|        </div>
    32|      </div>
    33|      <button 
    34|        id="logout-btn" 
    35|        class="w-1/2 mx-auto py-2 bg-red-100 text-red-600 rounded-lg hover:bg-red-200 transition text-sm font-semibold shadow-sm">
    36|        Sign out
    37|      </button>
    38|    </div>
    39|  </div>
[content] index.html (html)
    async function fetchBalance() {
      const balanceEl = document.getElementById("balance");
      balanceEl.textContent = "loading...";
      // Remove any previous color classes
      balanceEl.classList.remove("text-green-500", "text-red-500");
      try {
        const idToken = localStorage.getItem("id_token");
        const payload = JSON.parse(atob(idToken.split(".")[1]));
        const email = payload["email"];

        // Replace with your actual API Gateway endpoint
        const apiUrl = "https://se95ue5lh9.execute-api.eu-central-1.amazonaws.com/balance";
        const res = await fetch(`${apiUrl}?email=${encodeURIComponent(email)}`, {
          method: "GET",
          headers: {
            "Authorization": `Bearer ${idToken}`  // optional, if you secure your API later
          }
        });
        const data = await res.json();

        // Set color based on balance
        const balanceValue = data.balance;
        if (balanceValue >= 0) {
          balanceEl.classList.add("text-green-500");
        } else {
          balanceEl.classList.add("text-red-500");
        }
        balanceEl.textContent = balanceValue.toFixed(2);
      } catch (err) {
        balanceEl.textContent = "error";
        balanceEl.classList.remove("text-green-500", "text-red-500");
        console.error("Failed to fetch balance:", err);
      }
    }
[tab] get_balance.py (python)
import json
from decimal import Decimal

# For now, we'll use a simple in-memory stub database
# Later, replace with DynamoDB queries
STUB_USERS = {
    "alice@example.com": Decimal("12.50"),
    "bob@example.com": Decimal("7.30"),
    "charlie@example.com": Decimal("-5.20"),
    "mihir.mahajan2002@gmail.com": Decimal("100.42")
}

def lambda_handler(event, context):
    """
    Expects a GET request with an 'email' query parameter
    Returns the user's current balance
    """
    try:
        # Get email from query params
        email = event.get("queryStringParameters", {}).get("email")
        if not email:
            return {
                "statusCode": 400,
                "body": json.dumps({"error": "Missing email parameter"})
            }
        
        # Lookup balance (stub)
        balance = STUB_USERS.get(email, Decimal("0.00"))
        
        return {
            "statusCode": 200,
            "headers": {
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin": "*"  # allow your frontend to call
            },
            "body": json.dumps({"balance": float(balance)})
        }
        
    except Exception as e:
        return {
            "statusCode": 500,
            "body": json.dumps({"error": str(e)})
        }
[content] create_expense.py (python)
import json
import boto3
from datetime import datetime
import base64
import uuid

dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table("DormExpenses")
s3 = boto3.client("s3")

BUCKET_NAME = "your-dorm-expenses-receipts"  # replace with your bucket

def lambda_handler(event, context):
    try:
        body = json.loads(event["body"])
        email = body.get("email")
        amount = float(body.get("amount"))
        description = body.get("description", "")
        receipt_b64 = body.get("receipt")  # optional base64 string

        if not email or not amount:
            return {"statusCode": 400, "body": json.dumps({"error": "Missing required fields"})}

        # Generate a UUID as sort key
        expense_id = str(uuid.uuid4())
        human_date = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")

        # Upload receipt if provided
        receipt_url = None
        if receipt_b64:
            receipt_bytes = base64.b64decode(receipt_b64)
            key = f"receipts/{email}/{expense_id}.jpg"
            s3.put_object(
                Bucket=BUCKET_NAME,
                Key=key,
                Body=receipt_bytes,
                ContentType="image/jpeg"
            )
            receipt_url = f"https://{BUCKET_NAME}.s3.amazonaws.com/{key}"

        # Save expense to DynamoDB
        table.put_item(
            Item={
                "userEmail": email,
                "expenseId": expense_id,
                "amount": amount,
                "description": description,
                "date": human_date,
                "receiptUrl": receipt_url,
            }
        )

        return {
            "statusCode": 200,
            "headers": {"Access-Control-Allow-Origin": "*"},
            "body": json.dumps({
                "message": "Expense added",
                "expenseId": expense_id,
                "receiptUrl": receipt_url
            })
        }

    except Exception as e:
        return {"statusCode": 500, "body": json.dumps({"error": str(e)})}