cgi

Python urllib.request and utf8 decoding question

╄→гoц情女王★ 提交于 2019-12-21 06:18:05
问题 I'm writing a simple Python CGI script that grabs a webpage and displays the HTML file in the web browser (acting like a proxy). Here is the script: #!/usr/bin/env python3.0 import urllib.request site = "http://reddit.com/" site = urllib.request.urlopen(site) site = site.read() site = site.decode('utf8') print("Content-type: text/html\n\n") print(site) This script works fine when run from the command line, but when it gets to viewing it with a web browser, it shows a blank page. Here is the

CGIHTTPRequestHandler run php or python script in python

柔情痞子 提交于 2019-12-21 05:46:32
问题 I'm writing a simple python web-server on windows.. it works but now I want to run dynamic scripts (php or py) and not only html pages.. here is my code: from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler class RequestsHandler(CGIHTTPRequestHandler): cgi_directories = ["/www"] #to run all scripts in '/www' folder def do_GET(self): try: f = open(curdir + sep + '/www' + self.path) self.send_response(200) self.send_header('Content-type', 'text/html') self.end

Apache (2) throws “No such file or directory: exec of '/usr/lib/cgi-bin/fst.cgi' failed”

你说的曾经没有我的故事 提交于 2019-12-21 03:34:12
问题 I am working in Ubuntu 10.10 (Maverick Meerkat) and running my CGI script under Apache, but it is showing me the following error... [Sat errorNo such file or directory: exec of '/usr/lib/cgi-bin/fst.cgi' failed [Sat Oct 22 02:56:45 2011] [error] [client 127.0.0.1] Premature end of script headers: fst.cgi My script is #!/usr/bin/perl print "Content-type:text/html\n\n"; print "hello world"; I have set the permissions of the file... I have also added the following line in file apache.conf :

Configuring IIS 6.0 to execute cgi(.exe)

橙三吉。 提交于 2019-12-21 02:46:21
问题 I already create a virtual directory (cgi-bin) with permission : Scripts and Executable... When I test : http://localhost/cgi-bin/mapserv.exe, I got 404 error, The page cannot be found Am I supposed to Add a EXTENSION mapping to .exe files ? Which executable ? Thanks! 回答1: I solved that: Go to Web Service Extensions in the IIS service manager Select Add a new web service extension. On the required files tab, add C:\YourMapserverInstalldir\mapserv.exe Set it to allow Thanks anyway... 回答2: Yes,

Apache CGI in user directory “End of script output before headers”

有些话、适合烂在心里 提交于 2019-12-21 02:41:51
问题 I know there are some questions about this topic, but none seems to solve my issue. See this or this or this. I'm on Linux, Fedora21, and I'm trying to enable per user directory CGI script. I followed these instructions, but without success. I get the error: [cgi:error] End of script output before headers: test.cgi test.cgi is an executable sh file, containing a very simple script: #!/usr/bin/sh echo "Content-type: text/plain" echo "" echo "Hello" which has executable flag and runs without

Python 3, is using sys.stdout.buffer.write() good style?

一个人想着一个人 提交于 2019-12-21 01:39:13
问题 After I learned about reading unicode files in Python 3.0 web script, now it's time for me to learn using print() with unicode. I searched for writing unicode, for example this question explains that you can't write unicode characters to non-unicode console. However, in my case, the output is given to Apache and I am sure that it is capable of handling unicode text. For some reason, however, the stdout of my web script is in ascii . Obviously, if I was opening a file to write myself, I would

Trouble running python script as cgi under apache (ubuntu 12)

限于喜欢 提交于 2019-12-20 18:34:11
问题 Disclosure: I searched a lot, and I don't think my question (for my configuration) is answered here. For example run python script as cgi apache server doesn't answer it. So: I have a simplest script possible: #!/usr/bin/env python print "Content-type: text/html" print "" print "<h1>Hello from Python!</h1>" When I run it in a browser, it literally displays itself instead of expected Hello from Python! I did the following to make it run: a) it is executable by everyone; It runs in a shell

Is it possible to stream output from a python subprocess to a webpage in real time?

♀尐吖头ヾ 提交于 2019-12-20 17:00:30
问题 Thanks in advance for any help. I am fairly new to python and even newer to html. I have been trying the last few days to create a web page with buttons to perform tasks on a home server. At the moment I have a python script that generates a page with buttons: (See the simplified example below. removed code to clean up post) Then a python script which runs said command and outputs to an iframe on the page: (See the simplified example below. removed code to clean up post) This does output the

My first web app (Python): use CGI, or a framework like Django?

笑着哭i 提交于 2019-12-20 12:35:59
问题 I don’t want to burden you all with the details, but basically I’m a 2nd year compsci student with no Web dev experience. Basically I want to create a small “web app” that takes in input from a html form, have a python script perform some calculations, and re-display those results in your browser. As of right now, I have the form and script built. However, when I try to test the form, instead of running the script, my browser tries to download it. To my understanding, this is a cgi script

Hosting Mercurial HG via VisualSVN Server

旧街凉风 提交于 2019-12-20 10:54:30
问题 I have tried to host a Mercurial HG repository using a Scriptalias. ScriptAlias /hg/ "htdocs/hgwebdir.cgi" If I go to Chrome it display the contents of the cgi file. In IE it does render however images and links are not displayed. In either case the repository I want to display is not shown. Has anyone managed to get this working with VisualSVN? Also will this work if I have windows authentication and https? 回答1: Here's a alternative setup using mod_wsgi (fast!), combined repository directory