cotestatnt / async-esp-fs-webserver

ESP32/ESP8266 WebServer, WiFi manager and ACE web editor Arduino library. Based on ESPAsyncWebServer
Apache License 2.0
53 stars 14 forks source link

Hiding /setup page #48

Open spike7638 opened 1 month ago

spike7638 commented 1 month ago

Looking at lines 24-36 of AsyncFsWebServer.h, it's clear that there's supposed to be a way to say "I really don't want to have a /setup or /edit page." I've tried defining various things like ESP_FS_WS_SETUP or ESP_FS_WS_SETUP_HTM to be zero before #include "AsyncFsWebServer.h", but that leads to compilation errors like this:

In file included from /Users/jhughes/Documents/Projects/TankSensor/Web.h:12,
                 from /Users/jhughes/Documents/Projects/TankSensor/Web.cpp:4:
/Users/jhughes/Documents/Arduino/libraries/async-esp-fs-webserver-master/src/AsyncFsWebServer.h:135:5: error: 'SetupConfigurator' does not name a type
  135 |     SetupConfigurator* setup = nullptr;
      |     ^~~~~~~~~~~~~~~~~
/Users/jhughes/Documents/Arduino/libraries/async-esp-fs-webserver-master/src/AsyncFsWebServer.h:299:79: error: 'MIN_F' was not declared in this scope
  299 |     void addOption(const char *lbl, T val, bool hidden = false,  double min = MIN_F,
      |      
...

Is there a way that this is supposed to be done? By omitting sserver.enableFsCodeEditor(); from my .cpp file, I can get rid of the edit page, but I cannot figure out how to get rid of the setup page.

spike7638 commented 1 month ago

Please ignore this issue. I'll try to build a minimal non-working example and re-ask here or elsewhere.

IAmOrion commented 1 month ago

fwiw I also want to remove the setup - don't need it in my use case. The issue however is that creating an AP means it will trigger the captiveportal which is predefined as /setup Line 687 in AsyncFsWebServer.cpp on v1.0.7

cotestatnt commented 1 month ago

I'm sorry, but since it's a need that I've never had, even though I had foreseen this possibility, I never did any tests.

I just committed with the necessary changes. Obviously, by deactivating the /setup page, the captiveportal will have to be configured to redirect to a different url than /setupand so I added the method void setCaptiveUrl(const Strin& url)

If it will be necessary to access the WiFi, an alternative method to /setup will have to be foreseen to set the credentials.

I'll do some more testing and release a new version as soon as possible. In the meantime, if you want to try, you can update by downloading the zip file directly from github

spike7638 commented 1 month ago

I did a workaround, with a "reset" on the server, and then duplicating much of the stuff in the "init" procedure to include the 'pages' that I needed. In a perfect world (which it looks like your edit provides!), the "setup" page could be just as optional as the "edit" page, but for now, my modified version works OK.

On Thu, Oct 24, 2024 at 3:41 AM Tolentino Cotesta @.***> wrote:

I'm sorry, but since it's a need that I've never had, even though I had foreseen this possibility, I never did any tests.

I just committed with the necessary changes. Obviously, by deactivating the /setup page, the captiveportal will have to be configured to redirect to a different url than /setup and so I added the method void setCaptiveUrl(const Strin& url)

If it will be necessary to access the WiFi, an alternative method to /setup will have to be foreseen to set the credentials.

I'll do some more testing and release a new version as soon as possible. In the meantime, if you want to try, you can update by downloading the zip file directly from github

— Reply to this email directly, view it on GitHub https://github.com/cotestatnt/async-esp-fs-webserver/issues/48#issuecomment-2434531052, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWHAIX2UES7YKLVP7S47T3Z5CQEFAVCNFSM6AAAAABQCFSIUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZUGUZTCMBVGI . You are receiving this because you authored the thread.Message ID: @.***>