cgi

Upload a File with Python

陌路散爱 提交于 2019-11-30 09:20:37
I have an HTML form and I am using Python to generate a log file based on the input. I'd like to also be able to allow the user to upload an image if they choose. I can figure out how to manipulate it with Python once it's there, but I'm not sure how to get the image uploaded. This has most certainly been done before, but I'm having a hard time finding any examples. Can any of you point me in the right direction? Basically, I'm using cgi.FieldStorage and csv.writer to make the log. I want to get an image from the user's computer and then save it to a directory on my server. I will then rename

How to execute python script on the BaseHTTPSERVER created by python?

最后都变了- 提交于 2019-11-30 07:50:27
问题 I have simply created a python server with : python -m SimpleHTTPServer I had a .htaccess (I don't know if it is usefull with python server) with: AddHandler cgi-script .py Options +ExecCGI Now I am writing a simple python script : #!/usr/bin/python import cgitb cgitb.enable() print 'Content-type: text/html' print ''' <html> <head> <title>My website</title> </head> <body> <p>Here I am</p> </body> </html> ''' I make test.py (name of my script) an executed file with: chmod +x test.py I am

How can I encrypt and decrypt passwords in a Perl CGI program?

守給你的承諾、 提交于 2019-11-30 07:42:13
问题 Am new to Perl CGI, using ActivePerl, SQLite DB, Apache server and Windows. I have an entry form in which their are fields like Id, Name, Password and so on. Whenever anybody makes a new entry then whatever they enter into password field that should be encrypted and get stored in database. The next time when that same user enters the password then it should be validated. Now I suppose a decrypt function or code is required. I found something called MD5 encryption. Please can anybody give me

实战 Nginx 与 PHP(FastCGI)的安装、配置与优化

有些话、适合烂在心里 提交于 2019-11-30 07:37:53
一、什么是 FastCG I FastCGI是一个可伸缩地、高速地在HTTP server和动态脚本语言间通信的接口。多数流行的HTTP server都支持FastCGI,包括Apache、Nginx和lighttpd等,同时,FastCGI也被许多脚本语言所支持,其中就有PHP。 FastCGI是从CGI发展改进而来的。传统CGI接口方式的主要缺点是性能很差,因为每次HTTP服务器遇到动态程序时都需要重新启动脚本解析器来执行解析,然后结果被返回给HTTP服务器。这在处理高并发访问时,几乎是不可用的。另外传统的CGI接口方式安全性也很差,现在已经很少被使用了。 FastCGI接口方式采用C/S结构,可以将HTTP服务器和脚本解析服务器分开,同时在脚本解析服务器上启动一个或者多个脚本解析守护进程。当HTTP服务器每次遇到动态程序时,可以将其直接交付给FastCGI进程来执行,然后将得到的结果返回给浏览器。这种方式可以让HTTP服务器专一地处理静态请求或者将动态脚本服务器的结果返回给客户端,这在很大程度上提高了整个应用系统的性能。 二、Nginx+FastCGI 运行原理 Nginx不支持对外部程序的直接调用或者解析,所有的外部程序(包括PHP)必须通过FastCGI接口来调用。FastCGI接口在Linux下是socket,(这个socket可以是文件socket,也可以是ip

Set REMOTE_ADDR to X-Forwarded-For in apache

百般思念 提交于 2019-11-30 06:49:40
In a situation where Apache is sitting behind a reverse proxy (such as Squid), the cgi environment variable REMOTE_ADDR gets the address of the proxy rather than the client. However, the proxy will set a header called X-Forwarded-For to contain the original IP address of the client so that Apache can see it. The question is, how do we get Apache to replace REMOTE_ADDR with the value in the X-Forwarded-For header so that all of the web applications will transparently see the correct address? You can use mod_rpaf for that. http://stderr.net/apache/rpaf/ Note that the X-Forwarded-For header may

Set encoding in Python 3 CGI scripts

◇◆丶佛笑我妖孽 提交于 2019-11-30 04:45:41
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 name for plain ASCII. I now need to know how to make the cgi script run with 'utf-8' as the default

Where shall I start in making a scraper or a bot using python? [closed]

隐身守侯 提交于 2019-11-30 04:18:00
I'm not that new in programming languages(python) but I got no clue on where will I start in making a bot or a scraper using python?. should I study in cgi programming? or does the scraper runs just using a python script? Should I build a server for that? Got no clue for this... thanks for the help Brian Clapper Here are some links to get you started. Build a basic web scraper in Python Scrapy: An open source web scraping framework for Python Web scraping with Python. Part 1: Crawling If you’re trying to access websites that make heavy use of JavaScript, you might, overall, find Selenium

How do I create a webpage with buttons that invoke various Python scripts on the system serving the webpage?

人走茶凉 提交于 2019-11-30 03:02:10
I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities. I'd like to create a web page served from one of my systems that would merely present a few buttons which would allow me to initiate these scripts remotely. The problem is that I don't know where to start investigating how to do this. Let's say I have a script called: file_arranger.py What do I need to do to have a webpage execute that script? This isn't meant for

nginx-安装-虚拟主机-url重写-防盗链-限速-lnmp-反向代理

旧城冷巷雨未停 提交于 2019-11-30 01:10:47
✨✨安装 nginx-1.9.0.tar.gz tar xf nginx-1.9.0.tar.gz cd nginx-1.9.0. 依赖包: yum install -y pcre-devel zlib-devel gcc* cd nginx-1.9.0 ./configure --prefix=/usr/local/nginx (安装成功有提示一下文件路径文件名称)  nginx path prefix: "/usr/local/nginx" #安装目录 nginx binary file: "/usr/local/nginx/sbin/nginx"  执行文件 nginx configuration prefix: "/usr/local/nginx/conf"  配置文件路径 nginx configuration file: "/usr/local/nginx/conf/nginx.conf" 配置文件名称 nginx pid file: "/usr/local/nginx/logs/nginx.pid"        pid nginx error log file: "/usr/local/nginx/logs/error.log"  错误日志文件 nginx http access log file: "/usr/local/nginx/logs/access.log

should I reuse the cursor in the python MySQLdb module

匆匆过客 提交于 2019-11-30 00:32:04
问题 I'm writing a python CGI script that will query a MySQL database. I'm using the MySQLdb module. Since the database will be queryed repeatedly, I wrote this function.... def getDatabaseResult(sqlQuery,connectioninfohere): # connect to the database vDatabase = MySQLdb.connect(connectioninfohere) # create a cursor, execute and SQL statement and get the result as a tuple cursor = vDatabase.cursor() try: cursor.execute(sqlQuery) except: cursor.close() return None result = cursor.fetchall() cursor