|
| 1 | +# Web Handlers |
| 2 | + |
| 3 | +### / |
| 4 | + |
| 5 | +root is the default handler where all files will be served, if no file is defined, it looks for index.html or index.html.gz (compressed) |
| 6 | +if you call specific file, it will look for the filename and filename.gz (compressed) |
| 7 | +if no file is defined and there is not index.html(.gz) it will display embedded page |
| 8 | +another way to show the embedded page is /?forcefallback=yes |
| 9 | + |
| 10 | +### /sd/ |
| 11 | + |
| 12 | +it will serve any file from SD card if there is one, it is only a wrapper to read SD card, no upload |
| 13 | + |
| 14 | +### /files |
| 15 | + |
| 16 | +this handler handle all commands for FS, including upload on FS. |
| 17 | + possible options/arguments are: |
| 18 | + |
| 19 | +- `quiet=yes` can be used when you don't want list files but just upload them |
| 20 | +- `path=...` define the path to the file |
| 21 | +- `action=...` define the action to execute which can be: |
| 22 | + - delete |
| 23 | + delete the file defined by `filename=...` it will also use `path=...` to do full path |
| 24 | + - deletedir |
| 25 | + delete the directory defined by `filename=...` it will also use `path=...` to do full path |
| 26 | + - createdir |
| 27 | + create the directory defined by `filename=...` it will also use `path=...` to do full path |
| 28 | +- `createPath=yes` when doing upload and the path do not exists, it will create it, POST only |
| 29 | +- `<filename>S=...` give the size of uploaded file with <filename> name, need to be set before file is set in upload, POST only |
| 30 | + |
| 31 | +the output is a json file: |
| 32 | + |
| 33 | + ``` |
| 34 | + { |
| 35 | + "files":[ //the files list |
| 36 | + { |
| 37 | + "name":"index.html.gz", //the name of the file |
| 38 | + "size":"83.46 KB", //the formated size of the file |
| 39 | + "time":"2022-09-04 11:56:05" //the time when the file was modified last time, this one is optional and depend on (FILESYSTEM_TIMESTAMP_FEATURE) |
| 40 | + }, |
| 41 | + { |
| 42 | + "name":"subdir", //the name of the file / directory |
| 43 | + "size":"-1", //the size is -1 because it is a directory |
| 44 | + "time":"" //no time for directories optional as depend on (FILESYSTEM_TIMESTAMP_FEATURE) |
| 45 | + } |
| 46 | + ], |
| 47 | + "path":"/", //current path |
| 48 | + "occupation":"52", //% of occupation |
| 49 | + "status":"subdir created", //status |
| 50 | + "total":"192.00 KB", //Formated total space of Filesystem |
| 51 | + "used":"100.00 KB" //Formated used space of Filesystem |
| 52 | + } |
| 53 | + ``` |
| 54 | + |
| 55 | +### /sdfiles |
| 56 | + |
| 57 | +this handler handle all commands for SD, including upload on SD (only shared and direct SD) |
| 58 | +this handler handle all commands for FS, including upload on FS. |
| 59 | + possible options/arguments are: |
| 60 | + |
| 61 | +- `quiet=yes` can be used when you don't want list files but just upload them |
| 62 | +- `path=...` define the path to the file |
| 63 | +- `action=...` define the action to execute which can be: |
| 64 | + - list |
| 65 | + Will refresh the stats of the files - delete |
| 66 | + delete the file defined by `filename=...` it will also use `path=...` to do full path |
| 67 | + - deletedir |
| 68 | + delete the directory defined by `filename=...` it will also use `path=...` to do full path |
| 69 | + - createdir |
| 70 | + create the directory defined by `filename=...` it will also use `path=...` to do full path |
| 71 | +- `createPath=yes` when doing upload and the path do not exists, it will create it, POST only |
| 72 | +- `<filename>S=...` give the size of uploaded file with <filename> name, need to be set before file is set in upload, POST only |
| 73 | + |
| 74 | +the output is a json file: |
| 75 | + |
| 76 | + ``` |
| 77 | + { |
| 78 | + "files":[ //the files list |
| 79 | + { |
| 80 | + "name":"3Oc-pika2.gco",//the name of the file |
| 81 | + "shortname":"3Oc-pika2.gco", //the 8.3 shortname if available, if not the name of the file |
| 82 | + "size":"83.46 KB", //the formated size of the file |
| 83 | + "time":"2022-09-04 11:56:05" //the time when the file was modified last time, this one is optional and depend on (SD_TIMESTAMP_FEATURE) |
| 84 | + }, |
| 85 | + { |
| 86 | + "name":"subdir", //the name of the file / directory |
| 87 | + "size":"-1", //the size is -1 because it is a directory |
| 88 | + "time":"" //no time for directories optional as depend on (SD_TIMESTAMP_FEATURE) |
| 89 | + } |
| 90 | + ], |
| 91 | + "path":"/", //current path |
| 92 | + "occupation":"52", //% of occupation |
| 93 | + "status":"subdir created", //status |
| 94 | + "total":"192.00 KB", //Formated total space of Filesystem |
| 95 | + "used":"100.00 KB" //Formated used space of Filesystem |
| 96 | + } |
| 97 | + ``` |
| 98 | + |
| 99 | +### /upload |
| 100 | + |
| 101 | +this handler is for MKS boards using MKS communication protocol if enabled, it handle only upload on SD |
| 102 | + |
| 103 | +### /command |
| 104 | + |
| 105 | +this handler is for all commands the parameter is `cmd=...` |
| 106 | +if it is an `[ESPXXX]` command the answer is the `[ESPXXX]` response |
| 107 | +if it is not an `[ESPXXX]` command the answer is `ESP3D says: command forwarded` and can be ignored |
| 108 | + |
| 109 | +### /login |
| 110 | + |
| 111 | +this handler is for authentication function if enabled |
| 112 | +possible options/arguments are: |
| 113 | + - `DISCONNECT=YES` |
| 114 | +it will clear current session, remove authentication cookie, set status to `disconnected` and response code to 401 - `SUBMIT=YES` |
| 115 | +to login it will need also `PASSWORD=...` and `USER=...`, the answer will be 200 if success and 401 if failed |
| 116 | +if user is already authenticated it can use `NEWPASSWORD=...` instead of `PASSWORD=...` to change his password, if successful answer will be returned with code 200, otherwise code will be 500 if change failed or if password format is invalid |
| 117 | + |
| 118 | +Output: |
| 119 | + |
| 120 | +- if authentified and no submission: |
| 121 | + `{"status":"Identified","authentication_lvl":"admin"}` and code 200 |
| 122 | +- if not authenticated and no submission: |
| 123 | + `{"status":"Wrong authentication!","authentication_lvl":"guest"}` and code 401 |
| 124 | + |
| 125 | +### /config |
| 126 | + |
| 127 | +this handler is a shortcut to [ESP420] command in text mode, to get output in json add `json=yes` |
| 128 | + |
| 129 | +### /updatefw |
| 130 | + |
| 131 | +this handler is for FW upload and update |
| 132 | +Answer output is : |
| 133 | +`{"status":"..."}` if upload is successful the ESP will restart |
| 134 | + |
| 135 | +### /snap |
| 136 | + |
| 137 | +this handler is on esp32cam with camera enabled to capture a Frame |
| 138 | +it answer by sending a jpg image |
| 139 | + |
| 140 | +### /description.xml |
| 141 | + |
| 142 | +this handler is for SSDP if enabled to present device informations |
| 143 | + |
| 144 | +``` |
| 145 | +<root xmlns="urn:schemas-upnp-org:device-1-0"> |
| 146 | + <specVersion> |
| 147 | + <major>1</major> |
| 148 | + <minor>0</minor> |
| 149 | + </specVersion> |
| 150 | + <URLBase>http://192.168.2.178:80/</URLBase> |
| 151 | + <device> |
| 152 | + <deviceType>urn:schemas-upnp-org:device:upnp:rootdevice:1</deviceType> |
| 153 | + <friendlyName>esp3d</friendlyName> |
| 154 | + <presentationURL>/</presentationURL> |
| 155 | + <serialNumber>52332</serialNumber> |
| 156 | + <modelName>ESP Board</modelName> |
| 157 | + <modelDescription/> |
| 158 | + <modelNumber>ESP3D 3.0</modelNumber> |
| 159 | + <modelURL>https://www.espressif.com/en/products/devkits</modelURL> |
| 160 | + <manufacturer>Espressif Systems</manufacturer> |
| 161 | + <manufacturerURL>https://www.espressif.com</manufacturerURL> |
| 162 | + <UDN>uuid:38323636-4558-4dda-9188-cda0e600cc6c</UDN> |
| 163 | + <serviceList/> |
| 164 | + <iconList/> |
| 165 | + </device> |
| 166 | +</root> |
| 167 | +``` |
| 168 | + |
| 169 | +### Captive portal bypass handlers |
| 170 | + |
| 171 | +to avoid a redirect to index.html and so a refresh of the page, some classic handler have been added so they all go to / handler actually |
| 172 | + |
| 173 | +- /generate_204 |
| 174 | +- /gconnectivitycheck.gstatic.com |
| 175 | +- /fwlink/ |
0 commit comments