[R] an rpy2, R cgi type question

Collin Lynch collinl at cs.pitt.edu
Thu Oct 31 18:21:36 CET 2013


Not terribly verbose.  If you google it there is a cgitb flag you can set
to get verbose python output.  It is off by default for deployment as it
is a security hole but it is useful now.

	Collin.

On Thu, 31 Oct 2013, Erin Hodgess wrote:

> Hi again:
>
> Here is the web output:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was unable
> to complete your request.
>
> Please contact the server administrator, webmaster at erinm.info and inform
> them of the time the error occurred, and anything you might have done that
> may have caused the error.
>
> More information about this error may be available in the server error log.
>
> Additionally, a 404 Not Found error was encountered while trying to use an
> ErrorDocument to handle the request.
> I did indeed check permissions and they seem to be in order.
>
> Thanks,
> Erin
>
>
>
> On Wed, Oct 30, 2013 at 10:51 PM, Collin Lynch <collinl at cs.pitt.edu> wrote:
>
> > Erin can you share the internal error details?
> >
> > As a first guess are the files executable by all?  CGI requires world rwx.
> >
> >         Best,
> >         Collin.
> >
> > On Wed, 30 Oct 2013, Erin Hodgess wrote:
> >
> > > Hi again.
> > >
> > > I'm putting together a little project with R, python, and a website.  So
> > I
> > > have an HTML file, a py file, an R file.
> > >
> > > Here is the HTML file:
> > > <form action="/cgi-bin/radio4.py" method="post" target="_blank">
> > > <input type="radio" name="subject" value="Integrate" /> Integrate
> > > <input type="radio" name="subject" value="Differentiate" /> Differentiate
> > > <input type="radio" name="subject" value="Graph" /> Graph
> > > Function <input type="text"  name="func1" <br />
> > > <input type="submit" value="Select Subject" />
> > > </form>
> > >
> > > Now the radio4.py file:
> > >
> > > # Import modules for CGI handling
> > > import cgi, cgitb
> > > from sympy import *
> > > import sys
> > >
> > > from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage as
> > > STAP
> > > with open("bz2.R","r") as f:
> > >     string=''.join(f.readlines())
> > > etest = STAP(string,"etest")
> > > etest.etest(500)
> > >
> > >
> > > # Create instance of FieldStorage
> > > form = cgi.FieldStorage()
> > >
> > > # Get data from fields
> > > if form.getvalue('subject'):
> > >    subject = form.getvalue('subject')
> > > else:
> > >    subject = "Not set"
> > >
> > > if form.getvalue('func1'):
> > >    func1 = form.getvalue('func1')
> > > else:
> > >    func1 = "Not entered"
> > >
> > >
> > >
> > >
> > >
> > > print "Content-type:text/html\r\n\r\n"
> > > print "<html>"
> > > print "<head>"
> > > print "<title>Test Project</title>"
> > > print "</head>"
> > > print "<body>"
> > > print "<h2> Selected Action is %s</h2>" % subject
> > > print "<h3> output function is %s</h3>" % func1
> > > print "</body>"
> > > print "</html>"
> > >
> > >
> > > Finally, the bz2.R file:
> > >
> > > etest <- function(n=100) {
> > >     y <- rnorm(n)
> > >     pdf(file="lap1.png")
> > >     plot(y)
> > >     dev.off()
> > > }
> > >
> > >
> > > The radio4.py file is in a cgi-bin directory, along with the bz2.R file.
> > >
> > > I keep getting the Internal server error.
> > >
> > > Thanks for any help.
> > >
> > > Sincerely,
> > > Erin
> > >
> > > This is R version 3.0.2 and Python 2.7.5
> > >
> > > --
> > > Erin Hodgess
> > > Associate Professor
> > > Department of Computer and Mathematical Sciences
> > > University of Houston - Downtown
> > > mailto: erinm.hodgess at gmail.com
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> >
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>



More information about the R-help mailing list