\ Copyright 2021 Bradley D. Nelson \ \ Licensed under the Apache License, Version 2.0 (the "License"); \ you may not use this file except in compliance with the License. \ You may obtain a copy of the License at \ \ http://www.apache.org/licenses/LICENSE-2.0 \ \ Unless required by applicable law or agreed to in writing, software \ distributed under the License is distributed on an "AS IS" BASIS, \ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \ See the License for the specific language governing permissions and \ limitations under the License. ( Lazy loaded Server Terminal ) defer web-interface :noname r~ httpd also streams also httpd vocabulary web-interface also web-interface definitions r|esp32forth ESP32forth v7
Upload File:
| constant index-html# constant index-html variable webserver 2000 constant out-size 200 stream input-stream out-size stream output-stream create out-string out-size 1+ allot align : handle-index s" text/html" ok-response index-html index-html# send ; : handle-input begin body dup >r input-stream >stream pause r> 0= until out-string out-size output-stream stream> s" text/plain" ok-response out-string z>s send ; : serve-type ( a n -- ) output-stream >stream ; : serve-key ( -- n ) input-stream stream>ch ; : handle1 handleClient if s" /" path str= if handle-index exit then s" /input" path str= if handle-input exit then notfound-response then ; : do-serve begin handle1 pause again ; ' do-serve 1000 1000 task webserver-task : server ( port -- ) server ['] serve-key is key ['] serve-type is type webserver-task start-task ; only forth definitions web-interface ~ evaluate ; is web-interface
Legal: site web personnel sans commerce / personal site without seling