Revert "add input field"

This reverts commit c3ab24044f.
kirill 2 years ago
parent e1a15fa389
commit 740dfbcf51
  1. 112
      demo/templates/index.html

@ -12,76 +12,86 @@
min-height: 100vh;
background: linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 35%, rgba(0,212,255,1) 100%)
}
h1{
h1 {
text-align: center;
color: white;
text-shadow: 0 2px 5px rgba(150, 150, 150, 0.8);
}
#root {
display: flex;
flex-direction: column;
align-items: center;
}
p{
color:white;
.form {
width: 70%;
margin-bottom: 20px;
}
.container{
margin-left: 20vw;
.form__button {
text-align: center;
margin-top: 10px;
background-color: white;
cursor: pointer;
}
#submit{
margin-top: 20px;
border-radius: 10px;
height: 50px;
width:50vw;
color:black;
#myButton {
box-sizing: border-box;
width: 100%;
font-size: 18px;
outline: none;
border: none;
padding: 20px;
border-radius: 5px;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
transition: 0.3s;
-webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
}
#inputText{
border-radius: 10px;
height: 30px;
width: 49.5vw;
#myButton:hover {
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
transition: 0.3s;
-webkit-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
}
.container_result{
margin-top: 20px;
min-height: 50px;
#myResult {
text-align: center;
width: 50vw;
border: 3px solid white;
border-radius: 5px;
background-color: grey;
color: white;
text-shadow: 0 2px 5px rgba(150, 150, 150, 0.8);
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
<div>
<h1>Знакомство с aiohttp</h1>
<div id="root">
<div class="form">
<form id="myForm">
<input type="text" id="inputText" placeholder="Введите текст">
<div class="form__button"><button id='submit'>Отправить</button></div>
</form>
<div class="container_result">
<p id="response"></p>
</div>
</div>
<div class="form__button"><button id='myButton'>Отправить</button></div>
<p id="myResult"></p>
</div>
</div>
</body>
<script>
document.getElementById('myForm').addEventListener('submit', async function(event) {
event.preventDefault(); // Предотвращаем отправку формы по умолчанию
const inputText = document.getElementById('inputText').value;
const response = await fetch('/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
'text': inputText
})
$(document).ready(function() {
$("#myButton").click(function() {
$.ajax({
type: "POST",
url: "/button-clicked",
dataType: "json",
success: function(response) {
$("#myResult").text(response.result);
}
});
});
const responseText = await response.text();
document.getElementById('response').innerText = responseText;
});
</script>
</script>
</html>

Loading…
Cancel
Save