iisfox
Posts: 2
Joined: Tue Oct 21, 2014 1:15 pm

[help] Python change/refresh PHP page

Thu Jul 23, 2015 4:23 pm

Hi everyone.

First off all, sorry for my english, it is not my native language, so google will help me with this write task :D

I have a Raspberry running Apache, php5 and browser chormium on kiosk mode and everything works fine.

Now i need to make a python script to change/refresh php page everytime the gpio pin XX (ex 23) recieve a signal.

for exemple, i have 2 php pages (blackscreen.php and index.php), so when raspberry startup, the chromium will initiate with blackscreen.php and when gpio pin recieve a signal this page should be changed to index.php.

i tried the codes below

Code: Select all

import os, time
import RPi.GPIO as GPIO
import subprocess

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

while True:

        GPIO.wait_for_edge(23, GPIO.RISING)
	subprocess.call(["chromium", "http://192.168.0.1/index.php"])
        break
but in this case, a message appears saying that the browser is not allowed to run as root.

and with this code

Code: Select all

import os, time
import RPi.GPIO as GPIO
import webbrowser

GPIO.setmode(GPIO.BCM)

GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)

while True:

        GPIO.wait_for_edge(23, GPIO.RISING)
	webbrowser.open(http://192.168.0.1/index.php)
        break
Dillo browser is called everytime instead chromium and always in a new window.


thanks!

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: [help] Python change/refresh PHP page

Fri Jul 24, 2015 3:58 pm

try..

Code: Select all

import os

os.system("google-chrome ('http://192.168.0.1/index.php'")
..with both double and single quotes and, of course, the rest of your code!

Dave.
Apple say... Monkey do !!

iisfox
Posts: 2
Joined: Tue Oct 21, 2014 1:15 pm

Re: [help] Python change/refresh PHP page

Sat Jul 25, 2015 6:54 pm

Hi davef21370,

thanks for your answer, but even using your cue the browser keeps me returning the error message: "Chromium can not run as root".

Return to “Python”