Srikar00007 commited on
Commit
d37c2b2
Β·
verified Β·
1 Parent(s): 0c67b84

Update src/App.js

Browse files
Files changed (1) hide show
  1. src/App.js +10 -4
src/App.js CHANGED
@@ -3,6 +3,7 @@ import "./App.css";
3
 
4
  function App() {
5
 
 
6
  const API = "https://Srikar00007--Medical-Chatbot.hf.space";
7
 
8
  const [image, setImage] = useState(null);
@@ -10,6 +11,7 @@ function App() {
10
  const [question, setQuestion] = useState("");
11
  const [answer, setAnswer] = useState("");
12
 
 
13
  async function uploadImage(e) {
14
  const file = e.target.files[0];
15
  setImage(URL.createObjectURL(file));
@@ -26,6 +28,7 @@ function App() {
26
  setAnalysis(data);
27
  }
28
 
 
29
  async function askAI() {
30
  const res = await fetch(`${API}/ask-ai/`, {
31
  method: "POST",
@@ -48,19 +51,22 @@ function App() {
48
 
49
  <input type="file" accept="image/*" onChange={uploadImage} />
50
 
 
51
  {image && <img src={image} alt="Uploaded" className="preview" />}
52
 
 
53
  {analysis && (
54
  <div className="results">
55
- <h2>Detection Results</h2>
56
- <p><b>Wound Type:</b> {analysis.wound_label}</p>
57
  <p><b>Skin Disease:</b> {analysis.skin_label}</p>
58
  </div>
59
  )}
60
 
 
61
  {analysis && (
62
  <>
63
- <h2>Ask a Medical Question</h2>
64
 
65
  <input
66
  type="text"
@@ -72,7 +78,7 @@ function App() {
72
 
73
  {answer && (
74
  <div className="answer-box">
75
- <h3>AI Response</h3>
76
  <p>{answer}</p>
77
  </div>
78
  )}
 
3
 
4
  function App() {
5
 
6
+ // βœ… Your Hugging Face backend URL
7
  const API = "https://Srikar00007--Medical-Chatbot.hf.space";
8
 
9
  const [image, setImage] = useState(null);
 
11
  const [question, setQuestion] = useState("");
12
  const [answer, setAnswer] = useState("");
13
 
14
+ // βœ… Upload Image -> Analyze
15
  async function uploadImage(e) {
16
  const file = e.target.files[0];
17
  setImage(URL.createObjectURL(file));
 
28
  setAnalysis(data);
29
  }
30
 
31
+ // βœ… Ask AI
32
  async function askAI() {
33
  const res = await fetch(`${API}/ask-ai/`, {
34
  method: "POST",
 
51
 
52
  <input type="file" accept="image/*" onChange={uploadImage} />
53
 
54
+ {/* βœ… Show Uploaded Image */}
55
  {image && <img src={image} alt="Uploaded" className="preview" />}
56
 
57
+ {/* βœ… Show Analysis Results */}
58
  {analysis && (
59
  <div className="results">
60
+ <h2>πŸ” Detection Results</h2>
61
+ <p><b>Wound:</b> {analysis.wound_label}</p>
62
  <p><b>Skin Disease:</b> {analysis.skin_label}</p>
63
  </div>
64
  )}
65
 
66
+ {/* βœ… Ask Question */}
67
  {analysis && (
68
  <>
69
+ <h2>πŸ’¬ Ask a Medical Question</h2>
70
 
71
  <input
72
  type="text"
 
78
 
79
  {answer && (
80
  <div className="answer-box">
81
+ <h3>βœ… AI Response</h3>
82
  <p>{answer}</p>
83
  </div>
84
  )}