небольшие правки
This commit is contained in:
parent
d845eeae18
commit
59b876e2f2
|
|
@ -3,8 +3,12 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Определение породы собаки по фото</title>
|
<title>Определение породы собаки по фото</title>
|
||||||
|
<link rel="stylesheet" href="static/styles.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<section id="main">
|
||||||
|
<h1>Определить породу собаки по фото</h1>
|
||||||
|
<p>Загрузите фото, чтобы опеределить породу собаки или щенка. Если порода смешанная, после загрузки будет показана вероятность породы животного.</p>
|
||||||
<form enctype="multipart/form-data" method="post" action="/beeds" onsubmit="SavePhoto();return false">
|
<form enctype="multipart/form-data" method="post" action="/beeds" onsubmit="SavePhoto();return false">
|
||||||
<p><input type="file" name="f" id="file-input">
|
<p><input type="file" name="f" id="file-input">
|
||||||
<input type="submit" value="Отправить"></p>
|
<input type="submit" value="Отправить"></p>
|
||||||
|
|
@ -12,6 +16,7 @@
|
||||||
<div id="result"></div>
|
<div id="result"></div>
|
||||||
<img id="image" style="max-width: 200px;"/>
|
<img id="image" style="max-width: 200px;"/>
|
||||||
</body>
|
</body>
|
||||||
|
</section>
|
||||||
<script src="static/scripts.js"></script>
|
<script src="static/scripts.js"></script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
|
||||||
|
let urlCreator = window.URL || window.webkitURL;
|
||||||
|
|
||||||
async function SavePhoto()
|
async function SavePhoto()
|
||||||
{
|
{
|
||||||
let photo = document.getElementById("file-input").files[0];
|
let photo = document.getElementById("file-input").files[0];
|
||||||
|
|
@ -20,10 +23,14 @@ async function SavePhoto()
|
||||||
text += "<div>" + json.results[key] + ": " + key + "</div>";
|
text += "<div>" + json.results[key] + ": " + key + "</div>";
|
||||||
}
|
}
|
||||||
document.getElementById("result").innerHTML = text;
|
document.getElementById("result").innerHTML = text;
|
||||||
let urlCreator = window.URL || window.webkitURL;
|
|
||||||
let imageUrl = urlCreator.createObjectURL(photo);
|
|
||||||
document.getElementById("image").src = imageUrl;
|
|
||||||
} else {
|
} else {
|
||||||
alert("Ошибка HTTP: " + response.status);
|
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;
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue