cgi

How to run CGI “hello world” with python http.server

北慕城南 提交于 2019-11-28 09:48:52
I am using Windows 7 and Python 3.4.3. I would like to run this simple helloworld.py file in my browser: print('Content-Type: text/html') print( '<html>') print( '<head></head>') print( '<body>') print( '<h2>Hello World</h2>') print( '</body></html>') What I do is: 1) Go to command line C:\Python (where python is installed) 2) run: python -m http.server 3) Got to Firefox and type http://localhost:8000/hello.py However, instead of "Hello World", the browser just prints the content of the hello.py file. How can I fix it? From the http.server docs : CGIHTTPRequestHandler can be enabled in the

Start background process/daemon from CGI script

亡梦爱人 提交于 2019-11-28 09:45:47
I'm trying to launch a background process from a CGI scripts. Basically, when a form is submitted the CGI script will indicate to the user that his or her request is being processed, while the background script does the actual processing (because the processing tends to take a long time.) The problem I'm facing is that Apache won't send the output of the parent CGI script to the browser until the child script terminates. I've been told by a colleague that what I want to do is impossible because there is no way to prevent Apache from waiting for the entire process tree of a CGI script to die.

php-fpm

廉价感情. 提交于 2019-11-28 09:23:32
约定几个目录 /usr/local/php/sbin/php-fpm /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php.ini 一,php-fpm的启动参数 #测试php-fpm配置 /usr/local/php/sbin/php-fpm -t /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php .ini -y /usr/local/php/etc/php-fpm .conf -t #启动php-fpm /usr/local/php/sbin/php-fpm /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php .ini -y /usr/local/php/etc/php-fpm .conf #关闭php-fpm kill -INT ` cat /usr/local/php/var/run/php-fpm .pid` #重启php-fpm kill -USR2 ` cat /usr/local/php/var/run/php-fpm .pid` 二,php-fpm.conf重要参数详解 pid = run /php-fpm .pid #pid设置,默认在安装目录中的var/run/php-fpm.pid,建议开启

关于Tinyhttpd最全注释解析

我是研究僧i 提交于 2019-11-28 08:37:39
#include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <ctype.h> #include <strings.h> #include <string.h> #include <sys/stat.h> #include <pthread.h> #include <sys/wait.h> #include <stdlib.h> #include <stdint.h> #include "/usr/include/mysql/mysql.h" #define ISspace(x) isspace((int)(x)) #define SERVER_STRING "Server: zkphttpd/0.1.0\r\n" #define STDIN 0 #define STDOUT 1 #define STDERR 2 void search_mysql(int, char*); void accept_request(void *); void bad_request(int); void cat(int, FILE *); void cannot_execute

How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`?

混江龙づ霸主 提交于 2019-11-28 08:12:17
When I run python -m SimpleHTTPServer 8000 or python -m CGIHTTPServer 8000 in my shell I am hosting the content of my current directory to the internet. I would like to make the following cgi_script.py work correctly using the above command in the command line when I browse to 192.xxx.x.xx:8000/cgi_script.py #!/usr/bin/env python print "Content-Type: text/html" print print """\ <html> <body> <h2>Hello World!</h2> </body> </html> """ But this script is displayed literally and not only the "Hello World!" part. Btw I changed the file permissions to 755 for cgi_script.py as well as the folder I am

Python CGI - UTF-8 doesn't work

≯℡__Kan透↙ 提交于 2019-11-28 07:51:05
For HTML5 and Python CGI: If I write UTF-8 Meta Tag, my code doesn't work. If I don't write, it works. Page encoding is UTF-8. print("Content-type:text/html") print() print(""" <!doctype html> <html> <head> <meta charset="UTF-8"> </head> <body> şöğıçü </body> </html> """) This codes doesn't work. print("Content-type:text/html") print() print(""" <!doctype html> <html> <head></head> <body> şöğıçü </body> </html> """) But this codes works. Alexandr Tsyganok From https://ru.stackoverflow.com/a/352838/11350 First dont forget to set encoding in file #!/usr/bin/env python # -*- coding: utf-8 -*-

How to fetch HTTP headers in perl when using CGI

妖精的绣舞 提交于 2019-11-28 07:38:30
问题 I'm using Perl/CGI/Apache and want to fetch the X-Forwarded-For HTTP header. How do I do that? 回答1: Except for a few headers that are handled specially, CGI stores the value of Header-Name: in the environment variable HTTP_HEADER_NAME . So, X-Forwarded-For (if present in the request) should be found in $ENV{HTTP_X_FORWARDED_FOR} . 回答2: CGI has a method for accessing HTTP request header fields, called "http", so you can say: my $q = CGI->new() print $q->http('X-Forwarded-For'); This works

How to pass POST data to the PHP-CGI?

谁说我不能喝 提交于 2019-11-28 07:31:34
问题 Update: In a fit of desperation, I did the following in a shell: REDIRECT_STATUS=true SCRIPT_FILENAME=/var/www/... REQUEST_METHOD=POST GATEWAY_INTERFACE=CGI/1.1 export REDIRECT_STATUS export SCRIPT_FILENAME export REQUEST_METHOD export GATEWAY_INTERFACE echo "test=1" | php-cgi ...and STILL no $_POST variables are showing up in the output of this: <?php var_dump($_POST); ?> I am trying to create a small webserver that interfaces with the php-cgi binary. However, things aren't going so well.

Illegal operation on WrappedNative prototype object

天涯浪子 提交于 2019-11-28 07:26:39
问题 I'm sorry if this answer seems similar to other questions in this website, but I couldn't find what I need. I have this code: $.ajax({ url: '../../cgi-bin/executeQuery', type: 'GET', data: ({siid:5185,of:"xmlWithColID"}), dataType: 'xml', success: function(xmlR){ try{ $.ajax({ url: '../../cgi-bin/authList.py', type: 'GET', data: ({xmlToFormat:xmlR,service:"paperList"}), dataType: 'xml', success: function(data){ try{ displayResult(data,loadXMLDoc("js/authList/paperTableStyle.xsl"),

How to access variable of other perl program in my perl program

元气小坏坏 提交于 2019-11-28 06:03:16
问题 I have three different Perl programs. I want to access the value of a variable present in the first program in the other two Perl programs. My first Perl program look like the following: #!/usr/bin/perl print "Content-Type: text/html; charset=utf-8\n\n"; use CGI; use Cwd; use utf8; $q=new CGI; $a=$q->param('file'); #chomp($a); my $ftpname="$a"; This program takes value from a text of HTML program. I need the value of the $ftpname variable in my other to Perl programs. How can I do that? 回答1: