-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
140 lines (117 loc) · 4.56 KB
/
index.html
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Question Answering</title>
<!-- اضافه کردن لینک به فایلهای استایل بوتاسترپ -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KyZXEJ+T2Q5XsmRdtI8U52kPp0DrrduvXsEC0tma6rrsXkhgEMt4Y6jlnqIQQw4p" crossorigin="anonymous">
<!-- اضافه کردن آیکون فونت آوسام -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
<style>
body {
font-family: Arial, sans-serif;
background: url('https://ats.net/wp-content/uploads/Fokus-AI-Phonlamai-Shutterstock.jpg') no-repeat center center fixed;
background-size: cover;
color: #fff;
padding-top: 50px;
}
h1 {
text-align: center;
color: #fff;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.container {
background: rgba(0, 0, 0, 0.7);
padding: 30px;
border-radius: 10px;
max-width: 600px;
margin: auto;
}
.btn-submit {
background-color: #28a745;
color: white;
border: none;
width: 100%;
padding: 12px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
.btn-submit:hover {
background-color: #218838;
}
.form-label,
.form-control {
font-size: 18px;
}
.form-group {
margin-bottom: 20px;
}
#answer {
margin-top: 20px;
padding: 10px;
background-color: #f8f9fa;
border-radius: 5px;
color: #333;
}
.file-input {
font-size: 18px;
padding: 8px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1><i class="fas fa-question-circle"></i> Ask Questions from PDF</h1>
<form id="uploadForm" enctype="multipart/form-data">
<div class="form-group">
<label for="file" class="form-label">Upload PDF:</label>
<input type="file" id="file" name="file" accept="application/pdf" required class="form-control file-input" />
</div>
<div class="form-group">
<label for="question" class="form-label">Your Question:</label>
<input type="text" id="question" name="question" required class="form-control" />
</div>
<button type="submit" class="btn-submit">
<i class="fas fa-paper-plane"></i> Get Answer
</button>
</form>
<h2>Answer:</h2>
<p id="answer"></p>
</div>
<!-- اضافه کردن فایلهای جاوا اسکریپت بوتاسترپ -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-pzjw8f+ua7Kw1TIq0b6C5w3f6dp35A4sPe3Jt79p0wZ8sSY7b1sQ5hpkCUQ3eV5J" crossorigin="anonymous"></script>
<script>
const form = document.getElementById('uploadForm');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const fileInput = document.getElementById('file');
const questionInput = document.getElementById('question');
const answerElement = document.getElementById('answer');
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('question', questionInput.value);
try {
const response = await fetch('https://ee76-35-231-11-103.ngrok-free.app/upload', {
method: 'POST',
headers: {
'ngrok-skip-browser-warning': 'true' // اضافه کردن این هدر
},
body: formData
});
if (!response.ok) {
throw new Error('Error uploading file or processing question.');
}
const data = await response.json();
answerElement.innerText = `Answer: ${data.answer}`;
} catch (error) {
answerElement.innerText = `Error: ${error.message}`;
}
});
</script>
</body>
</html>