Raspberry Pi web pages (non embedded) location

For general Flowcode discussion that does not belong in the other sections.
RGV250
Posts: 283
http://meble-kuchenne.info.pl
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Raspberry Pi web pages (non embedded) location

Post by RGV250 »

Hi,
I need a little (read lot) of help here, I have a Raspberry Pi running with the embedded web pages, this has proved good for debugging etc but now I need to move on a bit and create my own which should be fun.
I have only found examples for ESP32 / 8266 but I think this is not for applicable for the Pi. It mentions the index.html file should be in the source directory or a specific one but that appears to be just for SD card.
From what I understand the Pi needs the Index.html file to be in directory ///var/www/html/
If this is the case do I just need to make the directory $(///var/www/html/) in the webserver source files property.

Regards,
Bob

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: Raspberry Pi web pages (non embedded) location

Post by BenR »

Hi Bob,

Currently the Webserver component in external file mode only works with the File SD component to take the files from an external SD card and this won't work on the RPI unless you have a second SD card connected to the IO pins.

However I've been developing a new component that will allow for direct file access on the RPI and I'm discussing it here.
viewtopic.php?p=8775#p8775

Hopefully it's something we can get working for you very soon. It is currently close, I need to get the directory navigation working and then we should be there.

RGV250
Posts: 283
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Re: Raspberry Pi web pages (non embedded) location

Post by RGV250 »

Thanks Ben,
Apologies for so many posts, I was a bit confused as to how it works, or not at the moment :)

Bob

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: Raspberry Pi web pages (non embedded) location

Post by BenR »

Hi Bob,

All working now for me, I've placed the website files in the same folder as the Flowcode project but you could try placing the files elsewhere. e.g. using a folder named web simply set the root directory to "web/" without the quotes. Files in sub directories etc should also be fine as long as the HTML contains the correct relative or absolute URL.

You could also try a root directory of "///var/www/html/" without the quotes for a more standard location for the html files to live.

You will need to goto Help -> Library Updates and change Files in use to Full database to get the latest component and CAL file.

Here's an example that's working well for me.
RPI_FileServer.fcfx
(14.39 KiB) Downloaded 366 times

I've also added float and long functions for the In and Out substitutions so hopefully should make things easier for you.

Let me know how you get on.

RGV250
Posts: 283
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Re: Raspberry Pi web pages (non embedded) location

Post by RGV250 »

Hi Ben,
Thanks for doing this, from what I have seen I assume that all I need to do is add "SetOutValueXX" and then add the corresponding %xx to my web page.

Regards,
Bob

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: Raspberry Pi web pages (non embedded) location

Post by BenR »

That's right Bob, any problems then let us know.

RGV250
Posts: 283
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Re: Raspberry Pi web pages (non embedded) location

Post by RGV250 »

Hi Ben,
I have finally got round to trying this out with a simple counter, so far no good.
This is the index.html file

Code: Select all

<html>
<title>Raspberry Pi Test Page</title>
<body>
  <h1>Raspberry Pi Test Page.</h1>
  TestData = %0 <br></h1>
  TestString = %1 </h1>
</body>
</html>
And this is the test file
RPI_Ext_Browser_Test_2.fcfx
(20.16 KiB) Downloaded 428 times
I have tried with the index.html file in /var/www/html/ and no data, I tried it in the project folder but could not get it to run. I may be doing it wrong but tried 192.168.1.220/home/pi/index.html and just got Not found error.

I would rather have the web pages in /var/www/html/ as that appears to be where they normally are but open to suggestions.

Bob

RGV250
Posts: 283
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Re: Raspberry Pi web pages (non embedded) location

Post by RGV250 »

I just wondered if there is any information as to how the transfer of data happens between the flowcode app and the web server. Is there any diagnostic software to see where the problem lies.

Bob

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: Raspberry Pi web pages (non embedded) location

Post by BenR »

Hi Bob,

First you need to remove the 1 second delay from your program as that will only add delay to the server being able to jump on page requests as they happen.

Also you don't currently need the SetFileIndex macro as you're not dealing with multiple files. I see you have the CSV component there too so I've left these in.

The File_RPI component has it's root folder set to nothing, this should be the same as the project folder, I've changed this to /var/www/html/ for you so hopefully the Pi will look in the html folder for the served files. Please note I haven't personally tried this but it should work ok.

Your web browser path should be 192.168.1.220/index.htm or for the index page you can get away with just 192.168.1.220

You had .html but the standard is usually .htm so this might be worth double checking.
RPI_Ext_Browser_Test_2.fcfx
(20.2 KiB) Downloaded 326 times

RGV250
Posts: 283
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 25 times
Been thanked: 32 times

Re: Raspberry Pi web pages (non embedded) location

Post by RGV250 »

Hi Ben,
The one second delay was so the number was incrementing fast but that does not matter for this test.
The file was modified from one where I had both CSV & webserver and I did not remove the setfile index (I think).
The index.html file was created when I followed a tutorial for setting up the webserver, at the moment I do not seem to be able to rename it, probably due to permissions.
I am wondering if the actual issue is the file locations. The web files are in /var/www/html which is where the tutorial says they should be and the flowcode project is in /home/pi/ which is where it is downloaded to and i do not think there is an option to redirect.
I did try to move the index.html to the same directory as the flowcode project but then I cold not see anything even if I tried to access the file directly.

Just out of curiosity, on another device where I use the embebded web page, where is it located as i do not have a /www/html/ folder and it is not in the flowcode project folder either?

Bob

Post Reply