mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #781] REST API instead of HTML Pages #653
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#653
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vip20 on GitHub (Dec 9, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/781
I want to create my own UI so changing this to REST API instead of a HTML page would be of a help
@ivanmonteiro commented on GitHub (Dec 10, 2018):
Also interested
@bkrajendra commented on GitHub (Apr 20, 2019):
Any plans on this?
It will be very cool if all routes are available as rest api by default and there is way to disable front end UI. It will open lot of possibilities for UI. Also might reduce the memory footprint if UI is totally removed. I understand that basic intention of developer must have been making a standalone interface for wificonfig, but many things have changed now and there are ways we can better put UI on clientside with hybrid apps, native apps, PWA, or many other method.
i know all routes are available now also and we can definitely interface any front-end with it, but its not optimized the way it should be for API consumption.
@tzapu @vip20 @ivanmonteiro
@vip20 commented on GitHub (Apr 20, 2019):
@bkrajendra can you try this https://github.com/vip20/esp8266-wifimanager
Let me know if any issues. I have been using this with Nativescript. I dont know where I got this from, but I edited for my own usecase
@bkrajendra commented on GitHub (Apr 20, 2019):
@vip20 i can try, but its always better to stick to original repo, as we can only get all updates in future from this repo. There are many available but its nice if API end points are available in original repo.!
I will look into the repo you provided and see if its helpful.
@vip20 commented on GitHub (Apr 20, 2019):
@bkrajendra, I get it, but I couldn't wait longer as I had to carry on with my project
@bkrajendra commented on GitHub (Apr 20, 2019):
yes.. im also waiting from long time, this feature is must. I was thinking of doing directly by sending POST/GET request from ionic app and handling html parsing at app side. this way @tzapu dont hve to change anything. but if little bit of HTML changed in WiFimanager it will break again. hence its better if simple JSON response is available from WM.
I dont if its possible or not in esp, but as im from web and mobile dev side, I know that on php server we can distinguish between ajax/rest client and browser through http headers. so its easy in server side to send selective response to client.
I'll have to look into how it can be done in esp.
@tablatronix commented on GitHub (Apr 20, 2019):
Please post a schema or routes suggesiton, development branch lets you add your own endpoints as webserver is public so it might be easy to hack into user code for now.
@bkrajendra commented on GitHub (Apr 20, 2019):
Thanks @tablatronix for taking interest !
As i said i was looking for some ways to detect XHR and normal browser requests and I found this simple solution by detecting headers:
for this to work we need to have collectHeaders in setup before server.begin() :
Now we can send selective response to clients. If its browser then HTML response and if its a Android/ioS native client or a IONIC webview client then JSON response.
Also http clients can send this ("User-Agent", "X-Requested-With") header if they want to get JSON.
@vip20 commented on GitHub (Apr 20, 2019):
@bkrajendra can you please let me know where to add this?
I am not able to connect to wifi using 0.14 please let me know if you face the same issue
@bkrajendra commented on GitHub (Apr 20, 2019):
@tablatronix
for API routes it can be something like:
GET api/v1/wifi
GET api/v1/wifinoscan
POST api/v1/wifisave
GET api/v1/info
GET api/v1/restart
GET api/v1/erase
GET api/v1/status
or better keep the routes same as now and use my previous solution to detect XHR/Browser. This will save lot of effort and avoid creating separate handlers. We can keep same handlers and just implement request detection.
@bkrajendra commented on GitHub (Apr 20, 2019):
@vip20 i was suggesting header solution to have REST client to get JSON response, so that we can connect through app. There are some other issues like keeping portal open etc. thats totally different issues. Also im not getting what exactly you are asking? I generally use Development branch only, even if it breaks sometime :)
@vip20 commented on GitHub (Apr 20, 2019):
@bkrajendra I'll try to implement it tomorrow, I badly need this feature, have you ever tried with firebase connection with esp8266?
@bkrajendra commented on GitHub (Apr 20, 2019):
No @vip20 , I generally use my own VPS servers with cloud and mqtt on it.
@tablatronix commented on GitHub (Apr 20, 2019):
I would rather implement an api endpoint and write custom api class, than have to add ajax checking to each callback just to keep it cleaner and be able to add features to api easier
@rvhani commented on GitHub (Jan 1, 2020):
I'm waiting for this. Rest API. sory for 1-liner.
@vip20 commented on GitHub (Jan 3, 2020):
@bkrajendra have any luck on this?
@laurensV commented on GitHub (Nov 27, 2022):
2.5 years later but would still be great to have this feature!
@laurensV commented on GitHub (Nov 27, 2022):
Or is there a different example of a wifimanger that exposes API endpoints so it can be setup through a mohile app for example?
@tablatronix commented on GitHub (Nov 28, 2022):
You can make your own api in user code