Code Monkey home page Code Monkey logo

Comments (7)

nrwiersma avatar nrwiersma commented on June 18, 2024

An example for this can be seen here: https://github.com/nrwiersma/ConfigManager/blob/master/examples/custom-http/custom-http.ino#L109

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on June 18, 2024

Hi,

like this way ?

server->on("/site", HTTPMethod::HTTP_GET, [server](){ server->on("/site", handle_OnConnect);

But there is no result...

Thanks a lot !

from configmanager.

nrwiersma avatar nrwiersma commented on June 18, 2024

No, like:

const char *siteHTML = (char *)"/site.html";

server->on("/site", HTTPMethod::HTTP_GET, [server](){
    configManager.streamFile(siteHTML, mimeHTML);
});

You will need to upload site.html into your SPIFFS. You can look to https://github.com/nrwiersma/ConfigManager#additional-files-saved for information.

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on June 18, 2024

Ah...
But, there is aktually no html-file as site.html. The ESP32 sends it as a String like:

`void handle_OnConnect() {

server.send(200, "text/html", SendHTML());

}

String SendHTML() {
String ptr = " \n";
ptr += "<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">\n";
ptr += "<title>BLEScanner f&uumlr Shelly</title>\n";
ptr += "<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
ptr += "body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;}\n";
ptr += "p {font-size: 24px;color: #444444;margin-bottom: 10px;}\n";
ptr += "</style>\n";
ptr += "\n";
ptr += "\n";
ptr += "<div id="webpage">\n";
ptr += "

BLEScanner f&uumlr Shelly

\n";
ptr += "

Gescanntes Device 1: ";
ptr += "\n";
ptr += "\n";
ptr += "\n";
return ptr;
}`

So, he generate the answer from his own code. Is this possible in combination with your libary ?

Thanks..

from configmanager.

nrwiersma avatar nrwiersma commented on June 18, 2024
... config manager setup
configManager.setAPICallback(APICallback);
....

void APCallback(WebServer *server) {
    server->on("/site", HTTPMethod::HTTP_GET, [server](){
        server.send(200, "text/html", SendHTML());
    });
}

from configmanager.

Stargazer32584 avatar Stargazer32584 commented on June 18, 2024

Tried it.
The following compilation error appears:

"request for member 'send' in 'server', which is of pointer type 'WebServer* const' (maybe you meant to use '->' ?)

Then, i switched to:

server->on("/site", HTTPMethod::HTTP_GET, [server](){ server->send(200, "text/html", SendHTML()); });

..and what should i say....?

Thanks again, man. It works...!!

Thanks a lot and best regards...

André

from configmanager.

nrwiersma avatar nrwiersma commented on June 18, 2024

No problem

from configmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.