cgi

How to hide “cgi-bin”, “.py”, etc from my URLs?

淺唱寂寞╮ 提交于 2019-12-02 18:29:07
Brand new to web design, using python. Got Apache up and running, test python script working in cgi-bin directory. Get valid results when I type in the URL explicitly: ".../cgi-bin/showenv.py" But I don't want the URL to look that way. Here at stackoverflow, for example, the URLs that display in my address bar never have the messy details showing the script that was used to run them. They're clean of cgi-bin, .py, etc. extensions. How do I do that? EDIT: Thanks for responses, every single one helpful, lots to learn. I'm going with URL Rewriting for now; example in the docs looks extremely

Configure Apache to use Python just like CGI PHP

好久不见. 提交于 2019-12-02 17:17:50
问题 I think one commonly known way of adding PHP to an Apache webserver is to configure it like this: ScriptAlias /php5.3 /usr/local/php5.3/bin Action application/php5.3 /php5.3/php-cgi AddType application/php5.3 .php Now I tried to write a similar configuration for Python: ScriptAlias /python /usr/bin Action application/python /python/python AddType application/python .py I have a small test script that looks like this: print "Content-Type: text/html\n\n" print "Test" But something seems to be

Why avoid CGI for Python with LAMP hosting?

元气小坏坏 提交于 2019-12-02 16:43:59
I have been using PHP for years. Lately I've come across numerous forum posts stating that PHP is outdated , that modern programming languages are easier, more secure, etc. etc. So, I decided to start learning Python . Since I'm used to using PHP, I just started building pages by uploading an .htaccess file with: addtype text/html py addhandler cgi-script .py Then, my sample pages look like: #!/usr/bin/python print "content-type: text/html\n\n" print "html tags, more stuff, etc." This works fine. But, I came across a comment in a post that said that CGI isn't the best way to use Python . Of

how to do client side sorting using querystring in hyperlink associated with the table header using Perl?

孤街醉人 提交于 2019-12-02 15:13:58
Hello everybody i hope everybody is doin well, Actually i have a table in which i fetch the data from sqlite database,i have done the paging and filtering for the grid using perl,now i need to do the sorting. The way in which i want to do is "MAKE THE TABLE HEADERS AS HYPERLINK AND WHENEVER I CLICK THEM THEN IT SHOULD SORT THE TABLE IN ASCENDING OR DESCENDING "ORDER BY" THE COLUMN WHICH I CLICK. Please do let me know is it possible, if yes then please do guide me find the solution. HERE'S My Code. Thank You. #!C:\perl\bin\perl.exe use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

Nginx+CGI/FastCGI+C/Cpp

旧巷老猫 提交于 2019-12-02 14:58:47
接着上篇《 Nginx安装与使用 》,本篇介绍CGI/FASTCGI的原理、及如何使用C/C++编写简单的CGI/FastCGI,最后将CGI/FASTCGI部署到nginx。内容大纲如下: 1. CGI 1.1. 环境变量 1.2. 标准输入 2. FastCGI 3. nginx cgi/fastcgi 3.1. nginx + fastcgi 3.1.1. spawn-fcgi 3.1.2. 编写 fastcgi 应用程序 3.1.3. nginx fastcgi 配置 3.2. nginx + cgi 3.2.1 fastcgi-wrapper 3.2.2. nginx fcgiwrap 配置 3.2.3. 编写 cgi 应用程序 参考链接 1.CGI 通用网关接口 ( C ommon G ateway I nterface/ CGI ) 描述了客户端和服务器程序之间传输数据的一种标准 ,可以让一个客户端,从 网页浏览器 向执行在网络 服务器 上的程序请求数据。 CGI 独立于任何语言的, CGI 程序可以 用任何 脚本语言 或者是完全独立 编程语言 实现, 只要这个语言可以在这个系统上运行。 Unix shell script, Python , Ruby , PHP , perl, Tcl , C / C++ , 和 Visual Basic 都可以用来编写 CGI

Software error while executing CGI script

ε祈祈猫儿з 提交于 2019-12-02 14:53:12
I have a cgi script for upload which is as follows #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; my $file = $cgi->param('file'); $file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename my $name = $2; open(LOCAL, ">/home/Desktop/$name") or die $!; while(<$file>) { $data .= $_; } print $cgi->header(); print "$file has been successfully uploaded... thank you.\n"; print $data; The HTML file is as follows <html> <head> <title>Test</title> </head> <body> <form enctype="multipart/form-data" action="upload.cgi" method="post"> <input type="hidden" name=

PHP 是怎么接收到请求的?

限于喜欢 提交于 2019-12-02 12:19:48
本篇文章主要描述一下几点 ● nginx 怎么转发请求 给 PHPFPM? ● CGI 和 FastCGI 到底是个什么玩意? ● PHPFPM 是什么?有什么作用? 简单场景描述 在浏览器上访问一个 php+nginx+mysql 构建的商城,并且购买一件商品。 分析 (这里访问的有两种资源) ● 静态资源(网站的一些图片,图标等) ● 动态资源 (购买商品的价格,商品的简介等) 浏览器发起请求 --> web_server(nginx)分发处理 --> php 执行代码返回结果 (这是大概的流程) nginx 是怎么分发请求? 当用户发起请求的时候 (浏览器默认请求 80 端口),nginx 监听到 80 端口,通过 nginx 配置正则匹配是否属于静态资源,如果是静态资源则返回文件,请求结束。如果是动态资源,通过 正则匹配到请求 php 脚本,那么他会通过 nginx 的模块 ngx_http_fastcgi_module 把请求分发给 PHPFPM 处理,然后处理完毕返回结果。 ● CGI CGI 是 Web 服务器运行外部程序的规范。意思就是通过 CGI 可以与你的程序通信,通过 CGI 标准格式。你的程序可以和浏览器交互。 (简单理解 CGI 就是一个协议,规定了一些东西该怎么传,你的程序这边怎么接受处理等规范。) ● PHP-CGI PHP-CGI 就是 CGI 协议

.cgi problem with web server

霸气de小男生 提交于 2019-12-02 11:20:47
问题 The code #!/usr/bin/env python import MySQLdb print "Content-Type: text/html" print print "<html><head><title>Books</title></head>" print "<body>" print "<h1>Books</h1>" print "<ul>" connection = MySQLdb.connect(user='me', passwd='letmein', db='my_db') cursor = connection.cursor() cursor.execute(“SELECT name FROM books ORDER BY pub_date DESC LIMIT 10”) for row in cursor.fetchall(): print "<li>%s</li>" % row[0] print "</ul>" print "</body></html>" connection.close() I saved it as test.cgi to

Output of command in Bash script to Drop-down box?

随声附和 提交于 2019-12-02 10:57:17
First off, I appreciate any and all help in answering this question. I have a command in a bash script that will output the following: 255 254 253 252 ... 7 6 5 4 3 2 1 It is a specific list of numbers, beginning with the largest (which is what I would like), then going to the smallest. The dataset is space-delimited. The output above (except including all numbers), is what you would see if you ran this command in the terminal on a linux machine, or through a bash script. I have configured my apache2 server to allow for cgi/bash through the cgi-bin directory. When I run this command in a bash

比较CGI,FastCGI,PHP-CGI与PHP-FPM的区别

那年仲夏 提交于 2019-12-02 10:42:14
最早的Web服务器,可以简单地响应浏览器发来的HTTP请求,并将存储在服务器上的HTML文件返回给浏览器,也就是静态html。 随着时间的变化,网站也越来越复杂,所以出现动态技术。但是服务器并不能直接运行 php,asp这样的文件,自己不能做,外包给别人吧,但是要与第三做个约定,我给你什么,然后你给我什么,就是握把请求参数发送给你,然后我接收你的处 理结果给客户端。那这个约定就是 common gateway interface,简称cgi 。 (cgi只是接口协议) image.png cgi就像翻译机,将PHP语言给服务器解释,便于相互之间的理解和通讯,最后呈现给浏览器查看 请求的动态页面模型.jpg WEB服务器将根据CGI程序的类型决定数据向CGI程序的传送方式,一般来讲是通过标准输入/输出流和环境变量来与CGI程序间传递数据。 如下图所示: image.png CGI程序通过标准输入(STDIN)和标准输出(STDOUT)来进行输入输出。此外CGI程序还通过环境变量来得到输入,操作系统提供了许 多环境变量,它们定义了程序的执行环境,应用程序可以存取它们。 Web服务器和CGI接口又另外设置了一些环境变量,用来向CGI程序传递一些重要的参 数。CGI的GET方法还通过环境变量QUERY-STRING向CGI程序传递Form中的数据。 下面是一些常用的CGI环境变量: 变量名