Броузер Опера и Эксплоуер вместо страницы с ответом типа Hello Bob!
выводит:
#!/Python34/python
import cgi
form = cgi.FieldStorage()
print('Content-type: text/html\n')
print('<title>Reply Page</title>')
if not ‘user’ in form:
print('<h1>Who are you?</h1>')
else:
print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form.value)
Изучаю книгу М. Луца программирование на Python 1 том. Основы CGI.
Остановился на примерах 1.30-1.31. Дальше не идет как нужно.
Пример 1.30. PP4E\Preview\cgi101.html
<html>
<title>Interactive Page</title>
<body>
<form method=POST action=“cgi-bin/cgi101.py”>
<P><B>Enter your name:</B>
<P><input type=text name=user>
<P><input type=submit>
</form>
</body></html>
Пример 1.31. PP4E\Preview\cgi-bin\cgi101.py
#!/usr/bin/python
import cgi
form = cgi.FieldStorage() # парсинг данных формы
print('Content-type: text/html\n') # http-заголовок плюс пустая строка
print('<title>Reply Page</title>') # html-разметка ответа
if not ‘user’ in form:
print('<h1>Who are you?</h1>')
else:
print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form.value))
cgi101.py поcле запуска выводит сообщение:
Content-type: text/html
<title>Reply Page</title>
<h1>Who are you?</h1>
После запуска cgi101.html выводится поле, в поле ввожу буквы, после нажатия на кнопку, просто появляется текст:
#!/Python34/python
import cgi
form = cgi.FieldStorage()
print('Content-type: text/html\n')
print('<title>Reply Page</title>')
if not ‘user’ in form:
print('<h1>Who are you?</h1>')
else:
print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form.value)
python на диске в папке С/Python34.
ОС Windows7.
Какие только варианты не перебирал в строке #!
все равно выводится:
#!/Python34/python
import cgi
form = cgi.FieldStorage()
print('Content-type: text/html\n')
print('<title>Reply Page</title>')
if not ‘user’ in form:
print('<h1>Who are you?</h1>')
else:
print('<h1>Hello <i>%s</i>!</h1>' % cgi.escape(form.value)
В чем ошибка?