небольшие правки

This commit is contained in:
artem 2023-04-30 20:58:01 +03:00
parent d845eeae18
commit 59b876e2f2
2 changed files with 23 additions and 11 deletions

View File

@ -3,15 +3,20 @@
<head>
<meta charset="UTF-8">
<title>Определение породы собаки по фото</title>
<link rel="stylesheet" href="static/styles.css">
</head>
<body>
<form enctype="multipart/form-data" method="post" action="/beeds" onsubmit="SavePhoto();return false">
<p><input type="file" name="f" id="file-input">
<input type="submit" value="Отправить"></p>
</form>
<div id="result"></div>
<img id="image" style="max-width: 200px;"/>
</body>
<section id="main">
<h1>Определить породу собаки по фото</h1>
<p>Загрузите фото, чтобы опеределить породу собаки или щенка. Если порода смешанная, после загрузки будет показана вероятность породы животного.</p>
<form enctype="multipart/form-data" method="post" action="/beeds" onsubmit="SavePhoto();return false">
<p><input type="file" name="f" id="file-input">
<input type="submit" value="Отправить"></p>
</form>
<div id="result"></div>
<img id="image" style="max-width: 200px;"/>
</body>
</section>
<script src="static/scripts.js"></script>
</html>

View File

@ -1,3 +1,6 @@
let urlCreator = window.URL || window.webkitURL;
async function SavePhoto()
{
let photo = document.getElementById("file-input").files[0];
@ -20,10 +23,14 @@ async function SavePhoto()
text += "<div>" + json.results[key] + ": " + key + "</div>";
}
document.getElementById("result").innerHTML = text;
let urlCreator = window.URL || window.webkitURL;
let imageUrl = urlCreator.createObjectURL(photo);
document.getElementById("image").src = imageUrl;
} else {
alert("Ошибка HTTP: " + response.status);
}
}
document.getElementById("file-input").addEventListener("change", function () {
let photo = document.getElementById("file-input").files[0];
let imageUrl = urlCreator.createObjectURL(photo);
document.getElementById("image").src = imageUrl;
});