You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" / >
< title > Знакомство с aiohttp< / title >
< style >
html {
font-family : Verdana , "sans-serif" ;
}
body {
min-height : 100 vh ;
background : linear-gradient ( 90 deg , rgba ( 2 , 0 , 36 , 1 ) 0 % , rgba ( 9 , 9 , 121 , 1 ) 35 % , rgba ( 0 , 212 , 255 , 1 ) 100 % )
}
h1 {
color : white ;
}
p {
color : white ;
}
. container {
margin-left : 20 vw ;
}
# submit {
margin-top : 20 px ;
border-radius : 10 px ;
height : 50 px ;
width : 50 vw ;
color : black ;
}
# inputText {
border-radius : 10 px ;
height : 30 px ;
width : 49.5 vw ;
}
. container_result {
margin-top : 20 px ;
min-height : 50 px ;
text-align : center ;
width : 50 vw ;
border : 3 px solid white ;
border-radius : 5 px ;
background-color : grey ;
}
< / style >
< / head >
< body >
< div class = "container" >
< 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 >
< / 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
} )
} ) ;
const responseText = await response . text ( ) ;
document . getElementById ( 'response' ) . innerText = responseText ;
} ) ;
< / script >
< / html >