cgi

Letting users upload Python scripts for execution

試著忘記壹切 提交于 2019-11-29 06:12:43
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. Any suggestions? (I'm looking for a solution that will work with my Python scripts) Have an extensive

Returning http status codes in Python CGI

拜拜、爱过 提交于 2019-11-29 05:44:57
Is it possible to send a status code other than 200 via a python cgi script (such as 301 redirect) Jiri via cgi script? print "Status:301\nLocation: http://www.google.com" Via wsgi application? def simple_app(environ, start_response): status = '301 Moved Permanently' # HTTP Status headers = [('Location','http://example.com')] # HTTP Headers start_response(status, headers) return [] 来源: https://stackoverflow.com/questions/833715/returning-http-status-codes-in-python-cgi

How can I get the entire request body with CGI.pm?

。_饼干妹妹 提交于 2019-11-29 05:37:35
I'm trying to write a Perl CGI script to handle XML-RPC requests, in which an XML document is sent as the body of an HTTP POST request. The CGI.pm module does a great job at extracting named params from an HTTP request, but I can't figure out how to make it give me the entire HTTP request body (i.e. the XML document in the XML-RPC request I'm handling). If not CGI.pm, is there another module that would be able to parse this information out of the request? I'd prefer not to have to extract this information "by hand" from the environment variables. Thanks for any help. You can get the raw POST

How can I serve unbuffered CGI content from Apache 2?

人走茶凉 提交于 2019-11-29 04:26:27
I would like to be able to allow a user to view the output of a long-running GCI script as it is generated rather than after the script is complete. However even when I explicitly flush STDOUT the server seems to wait for the script to complete before sending the response to the client. This is on a Linux server running Apache 2.2.9. Example python CGI: #!/usr/bin/python import time import sys print "Content-type: text/plain" print for i in range(1, 10): print i sys.stdout.flush() time.sleep(1) print "Done." Similar example in perl: #!/usr/bin/perl print "Content-type: text/plain\n\n"; for ($i

How do I access the HTTP Header of request in a CGI script?

你离开我真会死。 提交于 2019-11-29 03:07:20
I've used Perl a bit for small applications and test code, but I'm new to networking and CGI. I get how to make the header of a request (using CGI.pm and printing the results of the header() function), but haven't been able to find any info on how to access the headers being sent to my CGI script. Could someone point me in the right direction? This could be from a request like this: curl http://127.0.0.1:80/cgi-bin/headers.cgi -H "HeaderAttribute: value" The CGI module has a http() function you can use to that purpose: #!/usr/bin/perl -- use strict; use warnings; use CGI; my $q = CGI->new; my

C++微信网页协议实现和应用

筅森魡賤 提交于 2019-11-29 01:40:53
微信推送报警消息实现 目录 1 前言... 2 1.1 背景... 2 1.2 现有技术对比... 2 2 总体流程... 2 3 微信网页接口解析... 3 3.1 获取用户uuid. 3 3.2 获取二维码图片... 4 3.3 轮询检测用户是否登录... 4 3.4 重定向url登录微信并获取公参... 5 3.5 微信初始化... 5 3.6 获取联系人列表... 11 3.7 批量获取联系人详情... 13 3.8 检测是否有微信消息... 16 3.9 获取最新消息... 17 3.10 通过微信推送报警消息... 22 3.11 上传文件到微信服务器... 24 3.12 发送图片... 27 4 一些状态码code值的说明... 28 4.1 BaseResponse里的Ret 28 4.2 同步消息检查返回值中retcode和selector 28 4.3 返回消息类型... 29 5 实现操作步骤... 30 6 技术制约... 32 7 技术应用推广... 32 1 前言 1.1 背景 微信已经普遍被大家应用,而且手机微信方便快捷,可以随时随地的接受消息。目前项目中有需求通过微信推送报警消息。但是微信没有对外接口,无法实现报警推送。微信的方便快捷没有办法使用。可以通过微信的网页接口来实现微信的登录、获取好友信息、发送微信消息、获取微信消息等; 1.2

上传.cgi在252板子上跑

给你一囗甜甜゛ 提交于 2019-11-29 01:09:17
1.windows 下写好 .c 程序 2.进入 linux,准备交叉编译 arm-hisiv600-linux-gcc -g -Wall -o xxx.cgi xxx.c(交叉编译工具取决于板子) 3.把.cgi传给板子 4.赋给.cgi文件执行权限并执行 赋予权限: chmod 777 xxx.cgi 执行.cgi文件: ./xxx.cgi 附录: 作为办公室新人,没有Linux环境,没有交叉编译工具 1.下载SecureCRT,进入 公司服务器上啥都有的Linux环境 2.把.c程序上传到Linux服务器,准备交叉编译 1)打开SecureCRT左上角File>>Connect SFTP Session( Alt + P ),打开SFTP页面 2)例如要传的文件路径为(F:\ly-code\AI\stu-c\xxx.c ),在SFTP页面 输入 lcd F:\ly-code\AI\stu-c 3)再输入你要放Linux服务器的哪里:(我创建了一个新文件夹ly,就放在这里面,以免被老板批评说污染服务器的目录) cd ly 4)文件从哪里来,到哪里去设置好了,开始上传, 输入 put xxx.c 5)回到Linux把.c编译为.cgi,输入 arm-hisiv600-linux-gcc -g -Wall -o xxx.cgi xxx.c 3.把linux上的

Setting up Ruby CGI in Apache

我与影子孤独终老i 提交于 2019-11-28 23:22:51
I want to use Ruby in Apache through CGI. I have the following in my configuration file: DocumentRoot /home/ceriak/ruby <Directory /home/ceriak/ruby> Options +ExecCGI AddHandler cgi-script .rb </Directory> test.rb is a testfile placed under /home/ceriak/ruby/ , #!/usr/bin/ruby included on the first line and given executable permissions. Still, when I visit localhost/test.rb I get a download window and can obtain the source code. Interestingly, when I place the same script under /usr/lib/cgi-bin/ and call localhost/cgi-bin/test.rb it works as supposed. (Apache2 on Ubuntu 9.10.) Any idea? Few

PHP基础 CGI,FastCGI,PHP-CGI与PHP-FPM

允我心安 提交于 2019-11-28 21:28:20
CGI CGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上。 CGI可以用任何一种语言编写,只要这种语言具有标准输入、输出和环境变量。如php,perl,tcl等。 FastCGI FastCGI像是一个常驻(long-live)型的CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去fork一次(这是CGI最为人诟病的fork-and-execute 模式)。它还支持分布式的运算,即 FastCGI 程序可以在网站服务器以外的主机上执行并且接受来自其它网站服务器来的请求。 FastCGI是语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程保持在内存中并因此获得较高的性能。众所周知,CGI解释器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在内存中并接受FastCGI进程管理器调度,则可以提供良好的性能、伸缩性、Fail- Over特性等等。 FastCGI特点 FastCGI具有语言无关性. FastCGI在进程中的应用程序,独立于核心web服务器运行,提供了一个比API更安全的环境。APIs把应用程序的代码与核心的web服务器链接在一起,这意味着在一个错误的API的应用程序可能会损坏其他应用程序或核心服务器。

How can I add internationalization to my Perl script?

谁都会走 提交于 2019-11-28 20:46:25
I'm looking at introducing multi-lingual support to a mature CGI application written in Perl. I had originally considered rolling my own solution using a Perl hash (stored on disk) for translation files but then I came across a CPAN module which appears to do just what I want ( i18n ). Does anyone have any experience with internationalization (specifically the i18n CPAN module) in Perl? Is the i18n module the preferred method for multi-lingual support or should I reconsider a custom solution? Thanks There is a Perl Journal article on software localisation. It will provide you with a good idea