webserver implementation #21032
Replies: 3 comments 22 replies
-
It seems to have been missed in the docs, but among the "low level" functions in the BTW, there's also an "unmentioned" |
Beta Was this translation helpful? Give feedback.
-
here my code for testing:import webserver
|
Beta Was this translation helpful? Give feedback.
-
another problem. if i not insert the call to webserver.content_send_style() the page is not correct: the server send a page without the absent. Here the two page of the test, this with the webserver.content_send_style() present <title>Tasmota - No Login</title><script>var x=null,lt,to,tp,pc='';eb=s=>document.getElementById(s);qs=s=>document.querySelector(s);sp=i=>eb(i).type=(eb(i).type==='text'?'password':'text');wl=f=>window.addEventListener('load',f);function jd(){var t=0,i=document.querySelectorAll('input,button,textarea,select');while(i.length>=t){if(i[t]){i[t]['name']=(i[t].hasAttribute('id')&&(!i[t].hasAttribute('name')))?i[t]['id']:i[t]['name'];}t++;}}function sf(s){var t=0,i=document.querySelectorAll('.hf');while(i.length>=t){if(i[t]){i[t].style.display=s?'block':'none';}t++;}}wl(jd);function su(t){eb('f3').style.display='none';eb('f2').style.display='block';t.form.submit();}function upl(t){var sl=t.form['u2'].files[0].slice(0,1);var rd=new FileReader();rd.onload=()=>{var bb=new Uint8Array(rd.result);if(bb.length==1&&bb[0]==0xE9){fct(t);}else{t.form.submit();};};rd.readAsArrayBuffer(sl);return false;};function fct(t){var x=new XMLHttpRequest();x.open('GET','/u4?u4=fct&api=',true);x.onreadystatechange=()=>{if(x.readyState==4&&x.status==200){var s=x.responseText;if(s=='false')setTimeout(()=>{fct(t);},6000);if(s=='true')su(t);}else if(x.readyState==4&&x.status==0){setTimeout(()=>{fct(t);},2000);};};x.send();}</script><style>div,fieldset,input,select{padding:5px;font-size:1em;}fieldset{background:#4f4f4f;}p{margin:0.5em 0;}input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background:#dddddd;color:#000000;}input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px;}input[type=range]{width:99%;}select{width:100%;background:#dddddd;color:#000000;}textarea{resize:vertical;width:98%;height:318px;padding:5px;overflow:auto;background:#1f1f1f;color:#65c115;}body{text-align:center;font-family:verdana,sans-serif;background:#252525;}td{padding:0px;}button{border:0;border-radius:0.3rem;background:#1fa3ec;color:#faffff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}button:hover{background:#0e70a4;}.bred{background:#d43535;}.bred:hover{background:#931f1f;}.bgrn{background:#47c266;}.bgrn:hover{background:#5aaf6f;}a{color:#1fa3ec;text-decoration:none;}.p{float:left;text-align:left;}.q{float:right;text-align:right;}.r{border-radius:0.3em;padding:2px;margin:6px 2px;}.hf{display:none;}</style>To use Tasmota, please enable JavaScript Tasmota says no login!ESP32-DevKitTasmota-- |
Beta Was this translation helpful? Give feedback.
-
I am using berry language to publish my pages using the webserver interface. To allow the possibility for the berry code to use the standard methodology of authentication in the browser, it is possible to implement a function that request the webserver to send back the http code "401 Unauthorized" to force the remote browser to request username and password and then retreive the Authorization code from new request in the header (probably the .header allow this)?
Beta Was this translation helpful? Give feedback.
All reactions