How to make the “Lwip package” send a valid CGI response (data type is javascript )to HTML?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to make the “Lwip package” send a valid CGI response (data type is javascript )to HTML?

432 Views
Edward-Liao
Contributor I

Hi Sir:

My question is : How can I make the “Lwip package” send a valid CGI response (data type is javascript )to HTML?

 additional information, I use the IWIP package on application program.

Here is my HTML, I can make sure get a response but no data after checked:

    fetch("evse_para_req_high.cgi", { method: "GET" })

        .then(function(response) {

        console.log(response)

         })

        .catch(function(error) {

        console.log(`Error: ${error}`);

        });

 

Here is my C program on MCU:

 

static int cgi_para_req_high(HTTPSRV_CGI_REQ_STRUCT *param)

{

    HTTPSRV_CGI_RES_STRUCT response = {0};

 

    response.ses_handle             = param->ses_handle;

    response.status_code            = HTTPSRV_CODE_OK;

    response.content_length = -1;  

    

    response.content_type = HTTPSRV_CONTENT_TYPE_JS;

    response.data =  "console.log('Hello CGI')";

    response.data_length  = strlen(response.data);

    HTTPSRV_cgi_write(&response); 

 

    response.data_length = 0;

    HTTPSRV_cgi_write(&response);

   

    PRINTF("CGI execution cgi_evse_para_req_high\r\n");

    return (response.content_length);

}

 

Best Regards

Edward

0 Kudos
1 Reply

392 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Edward-Liao ,

  For the RT CGI to the HTML, you can refer to the RT SDK code:

\SDK_2_13_1_EVK-MIMXRT1060\boards\evkmimxrt1060\lwip_examples\lwip_httpsrv\freertos

  SDK download link:

  https://mcuxpresso.nxp.com/

If you have more issues, please use your company email to create the question post, it will have higher support priority, thanks.

Best Regards,

Kerry

0 Kudos