🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    http - get method - It does not send pairs name-value

    General
    4
    4
    7.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mario
      last edited by mario

      Hi,
      I am an accredited rookie ;-)

      When I try to send data through http, with the get method, it doesn't send the names and values pairs.

      UIflow with blocks:
      0_1580587604450_fba0daa1-709d-44d3-90cb-a8c1c9a73f2f-image.png

      When I look at the code, I don't see it send the string with the name and value pair.
      0_1580587570327_24d07e1c-3e64-4456-ac06-7f9982fede37-image.png

      According to this web page, the program would have to send you the data arguments.
      https://makeblock-micropython-api.readthedocs.io/en/latest/public_library/Third-party-libraries/urequests.html#urequests.request
      I have tried to write by hand, without success.

      Have any of the readers succeeded, send data to a server via http?

      This is the server code, written for node js, in case you want to try it at: https://repl.it/ o en https://glitch.com/

      var http = require('http');
      var url = require('url');
      
      var x_gyr = 0.0;
      
      /* https://echo-data-get-method-http-get.mariomoreno2020.repl.run/t.htm?x=15 */
      
      http.createServer(function (req, res) {
        // Set CORS headers
      	res.setHeader('Access-Control-Allow-Origin', '*');
      	res.setHeader('Access-Control-Request-Method', '*');
      	res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST, PUT');
      	res.setHeader('Access-Control-Allow-Headers', '*');
        res.statusCode = 200;
        //
        res.writeHead(200, {'Content-Type': 'text/html'});
        var q = url.parse(req.url, true);
        console.log(q.href);
        if (q.pathname == '/t.html') {
          q = q.query;
          x_gyr = q.x;
        }   
        var txt = 'x= ' + x_gyr;
        res.end(txt);
      }).listen(8080);
      

      Remember that the http block, the url is 'http' instead of 'https'.

      And if you want to try the UIFlow code, here is a download link. You can see how in the blocks it sends data and in the python code no.
      https://mega.nz/#!YY82UIrB!fskiB3YAn1hQH6rCcbwzjiuJO5-Fz0H4LBr6LZ4WtjI

      1 Reply Last reply Reply Quote 0
      • U
        uecken
        last edited by

        I got same problem.
        Here is my UiFlow code and server console.
        0_1650792706711_1c6db5e0-35d5-446b-ac50-fc34b85aff8e-image.png

        E 1 Reply Last reply Reply Quote 0
        • ajb2k3A
          ajb2k3
          last edited by

          Try placing the map functions inside the conver to JSON blocks.

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          1 Reply Last reply Reply Quote -1
          • E
            epollari @uecken
            last edited by

            @uecken Replace the text box containing the URL with an unescaped text box. That way, the URL won't get truncated. See also this post: HTTP GET query parameters

            1 Reply Last reply Reply Quote 0
            • First post
              Last post