• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Index 6

Q&A Forum › Category: ESP32 › Index 6
0 Vote Up Vote Down
Richard Holt asked 4 years ago

Hi Sara, I am working through the ESP32 course. I am at the server section where you (or Rui) say the following…
“Because the substrings we are looking for are always on index 6, we can add an if statement to detect the content of the request. “
I don’t understand this index 6 part. Would the index change if I were to use a different string, say ‘/?choice=timer’ as the request generated by the button? If the index would be different in that case, can you explain why and how I could work out what it would be. If it would be the same (6) please explain why.

Alternatively, perhaps you could point me to where there is an explanation. Thanks.

Question Tags: Question about the course
2 Answers
0 Vote Up Vote Down
Richard Holt answered 4 years ago

Aha… I think I get it….
The request string is “b’GET /?led=on” and the “b” is at index 0, therefore the searched string (/?led=on) starts at index 6, correct?

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi Richard.
 
Yes. That’s correct.
 
Alternatively, instead of using that method, you can use the find() function instead to search for a specific string within another string.
That function will return a number if found or -1 if not found. So, you can also create an if statement based on that condition.
Here you can find more information about the find() method: https://www.geeksforgeeks.org/python-string-find/
 
I hope this helps.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.