File size: 985 Bytes
cb2cdc8
 
 
 
 
 
 
 
 
 
 
 
 
 
ea314d3
 
3b81cd2
cb2cdc8
 
 
 
 
 
 
 
 
 
 
3b81cd2
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState } from "react";

export default function App() {
  const [input, setInput] = useState("");
  const [prediction, setPrediction] = useState("");

  const handlePredict = async () => {
    const res = await fetch("/api/predict", {
      method: "POST",
      body: JSON.stringify({ input }),
      headers: { "Content-Type": "application/json" }
    });
    const data = await res.json();
    setPrediction(data.prediction);
  };

  return (
    <div style={{ padding: "2rem", fontFamily: "sans-serif" }}>
      <h1>Stock Price Forecaster (LSTM)</h1>
      <input
        type="text"
        placeholder="Enter Ticker or Company Name"
        value={input}
        onChange={(e) => setInput(e.target.value)}
        style={{ padding: "0.5rem", width: "300px" }}
      />
      <button onClick={handlePredict} style={{ marginLeft: "1rem", padding: "0.5rem" }}>Predict</button>
      {prediction && <p>Predicted Next Day Close: ${prediction}</p>}
    </div>
  );
}