cgi

.cgi problem with web server

独自空忆成欢 提交于 2019-12-02 04:35:19
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 my web server. I run it by www.mysite.com/test.cgi unsuccessfully Internal Server Error The server

Perl script for file upload

↘锁芯ラ 提交于 2019-12-02 04:18:22
问题 I am trying to write a script in Perl that will allow the user to upload a file. At the moment, it says that it is working, but it does not actually upload the file! Here is the code: #!/usr/bin/perl use CGI; my $cgi = new CGI; my $dir = 'sub'; my $file = $cgi->param('file'); $file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename my $name = $2; open(LOCAL, ">$dir/$name") or print 'error'; while(<$file>) { print LOCAL $_; } print $cgi->header(); print $dir/$name; print "$file

JavaScript removing contents of form hidden by animatedcollapse.hide

怎甘沉沦 提交于 2019-12-02 04:03:10
I'm using JavaScript to hide and show div contents within a simple web form I made. However, I noticed that the submitted form (it sends the form as a dictionary to Python CGI) may still contain nonempty submitted values for hidden items. Usually, this happens because you enter some values into field X, click a link that hides the div containing field X, and then submit. I know that I can manually clear all of the input fields (i.e. field X, etc.) in a div when the div is hidden, but is there a more elegant way to accomplish this? With jQuery, you can make DOM manipulation both easy and

Apache的主要目录和配置文件详解

别来无恙 提交于 2019-12-02 02:50:16
Apache的主要目录和配置文件详解 来源于https://www.cnblogs.com/qianyuliang/p/6831942.html 一、Apache 主要配置文件注释 Apache的主配置文件:/etc/httpd/conf/httpd.conf 默认站点主目录:/var/www/html/ Apache服务器的配置信息全部存储在主配置文件/etc/httpd/conf/httpd.conf中,这个文件中的内容非常多,用wc命令统计一共有1009行,其中大部分是以#开头的注释行。 ServerTokens OS 在出现错误页的时候是否显示服务器操作系统的名称,ServerTokens Prod为不显示 ServerRoot "/etc/httpd" 用于指定Apache的运行目录,服务启动之后自动将目录改变为当前目录,在后面使用到的所有相对路径都是想对这个目录下 User daemon # apache的用户,默认为daemon Group daemon # apache的用户,默认为daemon PidFile run/httpd.pid 记录httpd守护进程的pid号码,这是系统识别一个进程的方法,系统中httpd进程可以有多个,但这个PID对应的进程是其他的父进程 Timeout 60 服务器与客户端断开的时间 KeepAlive Off 是否持续连接

PHP File upload - memory handling on CGI

江枫思渺然 提交于 2019-12-02 02:50:09
I'm wondering how PHP handles a file upload. I'v read a file upload will be split in chunks and will be assembled after the upload has finished. Is there any verification of this fact? This will help to understand the handling and settings for a file upload. Is the handling of mod_php or CGI the same? mod_php is more tied together with Apache. CGI has to read a stream and then do it's magic. How is the memory involved in this process. Is this correct? Apache handles HTTP request Apache calls PHP over CGI and streams data (pipe) PHP splits input in chunks of a certain size to not reach the

How to run Python CGI script

我的未来我决定 提交于 2019-12-02 01:09:58
问题 This question was migrated from Server Fault because it can be answered on Stack Overflow. Migrated 8 years ago . I have never setup a server (let alone a python server) before and i am a bit lost. How do i utilize the following code? I have tried to put in in the cgi bin directory but that didnt work. It returned an internal server error. have a look at this here #!/usr/bin/env python # # Funf: Open Sensing Framework # Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. #

Checkboxes with Perl CGI

拥有回忆 提交于 2019-12-02 00:50:11
问题 Sorry if my question is too simple, I am just starting out with CGI... So I have a bunch of checkboxes with the same name. Sample HTML: <form action="/cgi-bin/checkbox.cgi" method="POST"> <input name="Loc_opt" value="Loc_1" type="checkbox">Option 1<br> <input name="Loc_opt" value="Loc_2" type="checkbox">Option 2<br> <input name="Loc_opt" value="Loc_3" type="checkbox">Option 3<br> <input type="submit" value="Submit"> </form> I need to find out which of them are checked using Perl CGI. I have

Returning Output of Python CGI MySQL Script

时光怂恿深爱的人放手 提交于 2019-12-02 00:08:58
I'm very new to Python and MySQL and this is my first Stack question. So, apologies in advance if I'm missing something obvious. But, I really did try to research this before asking. I'm trying to learn the basics of Python, MySQL, and CGI scripting. To that end, I've been reading tutorials at http://www.tutorialspoint.com/python/python_cgi_programming.htm and http://www.tutorialspoint.com/python/python_database_access.htm , among others. I'm trying to have a CURL GET or Python Requests GET call a Python CGI script on a test server. That Python CGI script would then perform a Read action on a

接口测试“八重天”---RestAssured

两盒软妹~` 提交于 2019-12-01 23:47:04
要记住每一个对你好的人,因为他们本可以不那么做。               ---久节奏,慢读书 一、什么是RestAssured 偶然在逛帖子的时候发现一个接口测试框架,觉得不错,学习学习。 官方地址: http://rest-assured.io/ 那么瞧瞧官方是怎么说的: Testing and validating REST services in Java is harder than in dynamic languages such as Ruby and Groovy. REST Assured brings the simplicity of using these languages into the Java domain. 与动态语言(如Ruby或Groovy)相比,用java测试和验证REST服务要困难的多。RestAssured将使用这些语言的简单性带入java域。 可能前面也有记录过HttpClient相关的帖子,但是个人觉得RestAssured更为简单、便捷、易读! 二、RestAssured常规用法 官方文档: https://github.com/rest-assured/rest-assured/wiki/Usage Maven依赖: <dependency> <groupId>io.rest-assured</groupId>

Perl CGI with HTTP Status Codes

别来无恙 提交于 2019-12-01 19:24:30
I have the following validation in a CGI script that will check for the GET method and return a 405 HTTP status code if the GET method is not used. Unfortunately it is still returning a 200 Status OK when using POST or PUT. my ($buffer); # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; } else { $cgi->$header->status('405 Method Not Allowed') print $cgi->header('text/plain'); } I am still new to CGI programming so I figured someone here could toss me a bone about working with CGI and HTTP status returns. If a good CGI