cgi

How can I tell if a Perl script is executing in CGI context?

心已入冬 提交于 2019-12-19 06:03:36
问题 I have a Perl script that will be run from the command line and as CGI. From within the Perl script, how can I tell how its being run? 回答1: The best choice is to check the GATEWAY_INTERFACE environment variable. It will contain the version of the CGI protocol the server is using, this is almost always CGI/1.1 . The HTTP_HOST variable mentioned by Tony Miller (or any HTTP_* variable) is only set if the client supplies it. It's rare but not impossible for a client to omit the Host header

When should I use Perl CGI instead of PHP (or vice versa)?

北慕城南 提交于 2019-12-19 05:11:35
问题 For hobby purposes, I have a shared space on a hosting server that is providing, as many of them are, both PHP and Perl CGI. I have read on several places that CGI scripts are obsolete now, I think mainly for performance issues (like Is PHP or vanilla Perl CGI faster?). But since I just started studying Perl, I wouldn't want to waste time on implementing solutions in PHP that are way easier (or only possible) in Perl. Also there are the boilerplate issues, I'm aware of CPAN (that is the

Perl updating a value in .conf file from a form

做~自己de王妃 提交于 2019-12-19 04:58:19
问题 I have a admin.conf file and the file looks like this. For example, [online_offline_status] online_offline_status.online_offline_state = ONLINE i have another file called index.cgi that works as a form. For example, #!/usr/bin/perl #index.cgi require 'foobar-lib.pl'; ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1); ui_print_footer("/", $text{'index'}); print "Content-type:text/html\n\n"; print qq~ <html> <head> <link rel="stylesheet" type="text/css" href="cstyle17.css"> </head>

个人微信号接口分享,个人微信号API分享,微信协议分享,ipad协议探讨

孤街醉人 提交于 2019-12-18 21:31:08
发现了一个开源的个人API框架供大家讨论 亲测适配多个类型微信号及版本 二次开发魔改成功 目录: 接口介绍 接口服务端demo(python版) 消息回调接口 所有关于登陆事件 登陆二维码 登陆状态 登陆后获取个人信息或者其他的信息 好友列表详细信息 获取群列表 获取群成员列表 消息 网络获取联系人数据 新建群后返回群id 同意好友 获取v2 退出微信事件 手机退出微信触发事件 轮询消息接口 发送消息 发送文本消息 发送图片消息 发送文件消息 发送xml消息 发送名片消息 好友操作 获取联系人 添加好友 删除好友 查询好友信息 同意新好友 群操作 获取所有群列表 修改群名称 踢群成员 获取群成员列表 修改群备注名称 获取群成员v2然后就可以加好友 群邀请 其他操作 获取登陆状态 登陆二维码 退出登陆微信 接口介绍 一个软件开启一个微信程序,点击自定义接口,录入消息回调地址,轮询消息地址,点击立即保存,点击启动API即可。 消息回调地址:当 PC 微信有新事件产生,如收到新消息时,包括全部系统消息,都将通过该接口 post 消息到服务端。 轮询消息地址:可设置轮询时间间隔,定时轮询服务端是否有任务执行。 wechat多开,注意需要从客户端(WeQuick)唤起,一个客户端对应一个微信,对应一个processid。 接口服务端demo(python版) https://github

How can I fork a Perl CGI program to hive off long-running tasks?

我的未来我决定 提交于 2019-12-18 17:13:23
问题 I am writing a Bulk Mail scheduler controlled from a Perl/CGI Application and would like to learn abut "good" ways to fork a CGI program to run a separate task? Should one do it at all? Or is it better to suffer the overhead of running a separate job-queue engine like Gearman or TheSchwartz as has been suggested recently. Does the answer/perspective change when using an near-MVC framework like CGI::Application over vanilla CGI.pm? The last comes from a possible project that I have in mind for

lamp

雨燕双飞 提交于 2019-12-18 16:16:04
目录 1. lamp简介 2. web服务器工作流程 2.1 cgi与fastcgi 2.3 web工作流程 3. lamp平台构建 3.1 安装httpd 3.2 安装mysql 3.3 安装php 3.4 配置apache 3.4.1 启用代理模块 3.4.2 配置虚拟主机 3.5 验证 1. lamp简介 所谓lamp,其实就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一组动态网站或者服务器的开源软件,除Linux外其它各部件本身都是各自独立的程序,但是因为经常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。 LAMP指的是Linux(操作系统)、Apache(HTTP服务器)、MySQL(也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python)的第一个字母,一般用来建立web应用平台。 2. web服务器工作流程 web服务器的资源分为两种,静态资源和动态资源 静态资源就是指静态内容,客户端从服务器获得的资源的表现形式与原文件相同。可以简单的理解为就是直接存储于文件系统中的资源 动态资源则通常是程序文件,需要在服务器执行之后,将执行的结果返回给客户端 那么web服务器如何执行程序并将结果返回给客户端呢?下面通过一张图来说明一下web服务器如何处理客户端的请求 如上图所示

Set encoding in Python 3 CGI scripts

戏子无情 提交于 2019-12-18 11:45:47
问题 When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It seems that open() and print() use the return value of locale.getpreferredencoding() to know what encoding to use by default. When running on the command line, that value is 'UTF-8', as it should be. But when running the script through a browser, the encoding mysteriously gets redefined to 'ANSI_X3.4-1968', which appears to be a just a fancy

Printing HTML in Python CGI

只愿长相守 提交于 2019-12-18 05:21:36
问题 I've been teaching myself python and cgi scripting, and I know that your basic script looks like #!/usr/local/bin/python import cgi print "Content-type: text/html" print print "<HTML>" print "<BODY>" print "HELLO WORLD!" print "</BODY>" print "</HTML>" My question is, if I have a big HTML file I want to display in python (it had lines and lines of code and sone JS in it) do I have to manually add 'print' in front of each line and turn "s into \" , etc? Or is there a method or script that

How to distinguish between CLI & CGI modes in Perl

给你一囗甜甜゛ 提交于 2019-12-18 05:15:26
问题 I am supposed to write a Perl script which can be run both on the command line and as a CGI script. I haven't been able to determine how I should distinguish between the two modes. So could you please let me know how to implement the logic? 回答1: You can check for the presence of any number of CGI environment variables, e.g.: if ($ENV{GATEWAY_INTERFACE}) { print "Content-type: text/plain\n\nLooks like I'm a CGI\n"; } else { print "I'm just a plain command line program\n"; } 回答2: At a guess,

Letting users upload Python scripts for execution

时间秒杀一切 提交于 2019-12-18 04:42:12
问题 I understand that letting any anonymous user upload any sort of file in general can be dangerous, especially if it's code. However, I have an idea to let users upload custom AI scripts to my website. I would provide the template so that the user could compete with other AI's in an online web game I wrote in Python. I either need a solution to ensure a user couldn't compromise any other files or inject malicious code via their uploaded script or a solution for client-side execution of the game