Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Soil Report Analysis & Recommendations Generator</title> | |
<style> | |
/* Add your styles as needed */ | |
body { font-family: Arial, sans-serif; margin: 20px; } | |
.container { max-width: 900px; margin: auto; } | |
.flash-message { background-color: #f8d7da; color: #721c24; padding: 10px; border-radius: 5px; } | |
pre { background: #f4f4f4; padding: 15px; border-radius: 5px; } | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Soil Report Analysis & Recommendations Generator</h1> | |
<div class="upload-section"> | |
<h2>Upload Soil Reports</h2> | |
<form id="uploadForm"> | |
<input type="file" name="files" accept=".pdf,.jpg,.jpeg,.png" multiple required> | |
<div class="mb-4"> | |
<label for="language">Response Language</label> | |
<select id="language" name="language" required> | |
<option value="English">English</option> | |
<option value="Hindi">Hindi</option> | |
<option value="Bengali">Bengali</option> | |
<option value="Telugu">Telugu</option> | |
<option value="Marathi">Marathi</option> | |
<option value="Tamil">Tamil</option> | |
<option value="Gujarati">Gujarati</option> | |
<option value="Urdu">Urdu</option> | |
<option value="Kannada">Kannada</option> | |
<option value="Odia">Odia</option> | |
<option value="Malayalam">Malayalam</option> | |
</select> | |
</div> | |
<button type="submit">Generate Soil Analysis & Recommendations</button> | |
</form> | |
</div> | |
<div class="loading" id="loading" style="display:none;"> | |
<p>Analyzing soil reports and generating analysis...</p> | |
</div> | |
<div id="summaryContainer" style="display: none;"> | |
<h2>Analysis Result (JSON)</h2> | |
<pre id="jsonOutput"></pre> | |
</div> | |
</div> | |
<script> | |
document.getElementById('uploadForm').addEventListener('submit', function(e) { | |
e.preventDefault(); | |
const formData = new FormData(this); | |
const loading = document.getElementById('loading'); | |
const summaryContainer = document.getElementById('summaryContainer'); | |
const jsonOutput = document.getElementById('jsonOutput'); | |
loading.style.display = 'block'; | |
summaryContainer.style.display = 'none'; | |
fetch('/', { method: 'POST', body: formData }) | |
.then(response => response.json()) | |
.then(data => { | |
loading.style.display = 'none'; | |
summaryContainer.style.display = 'block'; | |
if (data.error) { | |
jsonOutput.textContent = data.error; | |
} else { | |
// Display the JSON data in a formatted way | |
jsonOutput.textContent = JSON.stringify(data, null, 2); | |
} | |
}) | |
.catch(error => { | |
loading.style.display = 'none'; | |
summaryContainer.style.display = 'block'; | |
jsonOutput.textContent = `Error: ${error.message}`; | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |