Ejemplo n.º 1
0
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Load a question file in the 'questions/' sub-directory, parse it,
# and return it to the caller in JSON format
QUESTIONS_DIR = '../questions/'

from parse_questions import parseQuestionsFile

import cgi, os, json

form = cgi.FieldStorage()
question_file = form['question_file'].value

fn = QUESTIONS_DIR + question_file + '.txt'
assert os.path.isfile(fn)


# Crucial first line to make sure that Apache serves this data
# correctly - DON'T FORGET THE EXTRA NEWLINES!!!:
print "Content-type: text/plain; charset=iso-8859-1\n\n"
print json.dumps(parseQuestionsFile(fn))
Ejemplo n.º 2
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Load a question file in the 'questions/' sub-directory, parse it,
# and return it to the caller in JSON format
QUESTIONS_DIR = '../questions/'

from parse_questions import parseQuestionsFile

import cgi, os, demjson

form = cgi.FieldStorage()
question_file = form['question_file'].value

fn = QUESTIONS_DIR + question_file + '.txt'
assert os.path.isfile(fn)

# Crucial first line to make sure that Apache serves this data
# correctly - DON'T FORGET THE EXTRA NEWLINES!!!:
print "Content-type: text/plain; charset=iso-8859-1\n\n"
print demjson.encode(parseQuestionsFile(fn))
Ejemplo n.º 3
0
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# Load a question file in the 'questions/' sub-directory, parse it,
# and return it to the caller in JSON format
QUESTIONS_DIR = '../questions/'

from parse_questions import parseQuestionsFile

import cgi, os, demjson

form = cgi.FieldStorage()
question_file = form['question_file'].value

fn = QUESTIONS_DIR + question_file + '.txt'
assert os.path.isfile(fn)


# Crucial first line to make sure that Apache serves this data
# correctly - DON'T FORGET THE EXTRA NEWLINES!!!:
print "Content-type: text/plain; charset=iso-8859-1\n\n"
print demjson.encode(parseQuestionsFile(fn))
Ejemplo n.º 4
0
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Load a question file in the 'questions/' sub-directory, parse it,
# and return it to the caller in JSON format
QUESTIONS_DIR = '../questions/'

from parse_questions import parseQuestionsFile

import cgi, os, json

form = cgi.FieldStorage()
question_file = form['question_file'].value

fn = QUESTIONS_DIR + question_file + '.txt'
assert os.path.isfile(fn)

# Crucial first line to make sure that Apache serves this data
# correctly - DON'T FORGET THE EXTRA NEWLINES!!!:
print "Content-type: text/plain; charset=iso-8859-1\n\n"
print json.dumps(parseQuestionsFile(fn))