[R] an rpy2, R cgi type question
R. Michael Weylandt <michael.weylandt@gmail.com>
michael.weylandt at gmail.com
Thu Oct 31 13:04:54 CET 2013
On Oct 31, 2013, at 1:50, Erin Hodgess <erinm.hodgess at gmail.com> 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.
So your Python code is raising an exception somewhere, not the apache config.
>
> 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.
Can you check these?
>
> 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.
Yes, they do seem to be; you'd be getting a 403 otherwise.
>
> 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
>
> [[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.
More information about the R-help
mailing list