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