cgi

Displaying matplotlib plot in CGI with cStringIO

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:55:48
问题 Trying to return a simple plot (saved in StringIO) to web browser. After hours of reading, finally getting close, maybe. import cgi import cStringIO import matplotlib.pyplot as plt import numpy as np def doit(): x = np.linspace(-2,2,100) y = np.sin(x) format = "png" ggg = cStringIO.StringIO() plt.plot(x, y) plt.savefig(ggg, format=format) data_uri = ggg.read().encode('base64').replace('\n', '') img_tag = '<img src="data:image/png;base64,{0}" alt="thisistheplot"/>'.format(data_uri) print(

How to upload image file using cgi program written in c language?

北慕城南 提交于 2019-12-11 04:55:20
问题 I wanted to upload a jpeg image file on the server.I have a GoAhead web server which supports only cgi c program as a serverside handeling. Can any one know how to handle http posted image file in program witten in cgi in c language? 回答1: To get POST data just read stdin. Environment variable CONTENT_LENGTH tells you how much to expect but of course you need to make your code robust against whatever a potentially malicious user can throw at you. 回答2: The GoAhead web server has a file upload

Run superuser command from perl-CGI script via apache

走远了吗. 提交于 2019-12-11 04:53:48
问题 I do have a script where I can run native OS command (non-superuser command) #!/usr/bin/perl print "Content-type: text/html\n\n"; system("ls -lrt"); and this works fine. System Command output is displayed on Web page.. However, I have my own binary "get_stats" (with super-user privileges) placed at /sbin directory. But web page appears blank, system command output is not displayed on the webpage. #!/usr/bin/perl print "Content-type: text/html\n\n"; system("get_stats"); What are the changes

IIS 8.5 serving dll for download instead of executing

六眼飞鱼酱① 提交于 2019-12-11 04:47:53
问题 The Problem: When I access a (32-bit) DLL via URL like http://localhost/somepath/some.dll?action IIS always thinks I want to download the file (with file size 0 byte) instead of executing the dll. What I tried so far: added an entry for this specific DLL in ISAPI- and CGI-Restrictions enabled the "ISAPI-dll" Handler for *.dll with feature permissions read,script and execute. IIS User / AppPool Identity have full access rights to the physcal location of the dll App-Pool is running in classic

How do I call a python function with parameters in CGI?

人盡茶涼 提交于 2019-12-11 04:32:06
问题 I want to build an interface for browsing an Apache2 server using python scripts. I spent the past days learning python and today getting familiar with CGI. I want to test out some stuff, like the possibility for the user to navigate to the path he wants from the base directory /var/www/cgi-bin by inputting the path he wants to visit, for example /etc/httpd/conf.d . For that i have the change_path.py script which looks like this: import os def changePath(path): os.chdir(path) I already got

Running CGI on Jetty

一笑奈何 提交于 2019-12-11 04:00:06
问题 I'm starting Jetty from inside the Java program itself. I'm simply trying to get it to point at a cgi-folder that I've placed underneath the package directory (/src/package/cgi-bin) The problem is that every time I start up the server, it complains "no CGI bin!". Where is the correct location to put your cgi-bin and point at it? This is what I have: public static void main(String[] args) throws Exception { // The core Jetty server running on 8080 Server server = new org.eclipse.jetty.server

cgicc - cgi.getElements(), which method? get or post?

試著忘記壹切 提交于 2019-12-11 03:59:40
问题 cgicc can process form elements quite well , but how can i know whether the data is generated from get_method or post_method? the piece of code i used: cout << "Content-type:text/html\r\n\r\n"; try { Cgicc cgi; const_form_iterator iter; for(iter = cgi.getElements().begin(); iter != cgi.getElements().end(); ++iter){ cout << "<table><tr>" << "<td>" << iter->getName() << "</td>" << "<td>" << iter->getValue() << "</td>" << "</tr></table>" << endl; } }catch(exception& e) { cout << e.what() << endl

The specified CGI application misbehaved… when executing hgweb.cgi for Mercurial

旧时模样 提交于 2019-12-11 03:57:13
问题 I have IIS 6 I installed Mercurial in c:/program files/mercurial I installed Python 2.6 in c:/program files/python I added extension handlings etc for my websites under tab 'home directory'=>'configuration "C:\program files\Mercurial\python\python.exe" -u "%s" "%s" extenstion = .cgi I allowed python.exe in web service extensions "C:\Program Files\Mercurial\Python\python.exe" -u "%s" "%s" I allowed all unknown cgi, although it is not recommended for security reasons I have a website on E:\WWW\

unable to run java command from cgi

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:44:08
问题 I have this function to read a doc file using tika on linux: def read_doc(doc_path): output_path=doc_path+'.txt' java_path='/home/jdk1.7.0_17/jre/bin/' environ = os.environ.copy() environ['JAVA_HOME'] =java_path environ['PATH'] =java_path tika_path=java_path+'tika-app-1.3.jar' shell_command='java -jar %s --text --encoding=utf-8 "%s" >"%s"'%(tika_path,doc_path,output_path) proc=subprocess.Popen(shell_command,shell=True, env=environ,cwd=java_path) proc.wait() This function works fine when I run

How to load the RVM part of user's .bashrc to run Ruby CGI scripts under Apache?

徘徊边缘 提交于 2019-12-11 03:37:49
问题 I've configured a new server on Ubuntu 12.04 and I started to use RVM. I've installed RVM under my user (as myself, not as root with sudo) by following the Ryan Bigg's guide, with no previous system-wide installed Ruby. So, I didn't have any Ruby under /usr/bin. My first task then was to replace the shebang line of all my CGI scripts, from !#/usr/bin/ruby to !#/usr/bin/env ruby However my scripts didn't run under Apache. In the terminal I could run them (by typing ./index.cgi , for example),