Using the Webviewer

Before I jump into learning the webviewer, I would like to ask if I can use the viewer to do this task.

I am running a simple Arduino web server that works.

Can I send a request such as “http://mysite.netgear.com:8085/status” ?
This request uses dynamic DNS to get to my local server and I have selected port 8085 that will be forwarded to my Arduino server, with the command status.

My site will respond with a string such as “light 1 is on”.
Is there a function in the Webviewer that will display the received string so that I can parse it and then do other things based on the result?

See here: App Inventor Code Snippets | Pura Vida Apps

you might want to use the Web component for this
http://ai2.appinventor.mit.edu/reference/components/connectivity.html#Web
the response will be returned in the Web.GotText event then
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

I can see I need to do some studying.

I have attempted to start an app and inserted a button and webviewer.
When I pushed the button I execute the procedure “webviewer1.gotoURL” where I have a URL inserted as a text box. When I push the button, I get a response that the web page cannot be accessed. I know this is not true as I can access the page from my PC. I know this is very simple but I have to start simple.

An aside question, how or what is the best way to be able to insert some blocks into my reply’s?

as already said, use the web component

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.


A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Sometimes the easiest things seem hard. I have a file of my blocks but I see no option to insert the file into a reply.

Unbenannt

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

block1

I am making some progress. In the blocks I am trying to send to “http://hambo.mynetgear.com:8085/file1
It seems that I cannot add the port number 8085. Is thee a way to do this?

Without the port number, I cannot get through my router to my specific server.
Suggestion??

try this
Unbenannt
see also the documentation to understand the properties...
http://ai2.appinventor.mit.edu/reference/components/connectivity.html#Web

SaveResponse
Whether the response should be saved in a file.

do the tutorials to learn the basics!
How to work with the web component and an API byStephen
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

I have the property page you reference in front of me but it is not very clear unless you have worked with web pages before.

When I try to use a URL with a port number, I get an error that it is an invalid URL. I do not see in the doc you suggest as to how to specify a port.

I want to get the response whatever it is so I can look for the string “file1”

If you use your computer and send to the URL http://hambo.mynetgear.com:8085/file1 you will get a response of “file 1 selected” This is what I want to achieve using MIT Inventor.

Taifun, any ideas for me about the port issue?

It doesn’t look like Stephen addressed the port issue.

If you change file1 to file2 you will get a different response.

I tried this, but did not get a response…
Unbenannt
probably someone else has an idea?
Taifun

hambo.aia (2.0 KB)

I noticed that my server has responded to a request a few times so I guess the request is going out.
What my server does is to merely look at the received string and look for “file1” or “file2” then it responds with either “file1 selected” or file2 selected.

At least you are getting the app to send to a URL with a port number;

I am not sure why you cannot see the response.

Me2,

Taifun, I tried the code (blocks) you posted and get no results. Not sure what is happening here. I am connecting to the ai companion on my cell phone.

Correction, your code blocks do work. My server crashed for some reason and I had to reboot it. Now your code works but still no response.

Are you testing with a cell phone or the emulator on the computer. I just tried the computer emulator and it worked although I have had to update it a few times.

I do appreciate you helping me with this.

It seems that we are sending the request but having trouble getting the “file 1 selected” response.

Hello Taifun… Are we giving up on this app?

The problem is here:

http://hambo.mynetgear.com:8085/file1

If the fault is in the Arduino web server,
post the code for the Arduino web server.