Note that the first example could be a infinitive loop, where it does
not get to the return statement, never the less prints should show
up ?
# WEB OUTPUT
# LOG OUTPUT
import os,sys
def application(environ, response):
print('STDERR %s' % __file__, file=sys.stderr)
#query=environ.get['QUERY_STRING']
query=os.path.join(os.path.dirname(__file__),'teeeeeeeeeemp')
print('test',file=environ['wsgi.errors'])
range=environ.get('HTTP_RANGE','bytes=0-').replace
('bytes=','').split(',')
offset=[]
for r in range: offset.append(r.split('-'))
with open(query,'wb') as f
f.seek(offset[0][0])
while True:
chunk=environ['wsgi.input'].read(8192).decode('latin1')
if not chunk: break
f.write(chunk)
l=os.fstat(f.fileno()).st_size
response('200 OK', [('Content-Type', 'text/plain'), ('Content-
Length', str(len(l)))])
return [l]
#500 Internal Server Error
#
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
print('STDERR %s' % __file__, file=sys.stderr)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
#Hello World!
#[Mon Aug 17 19:08:53 2009] [error] STDERR /usr/httpd/www/appwsgi/wsgi/
upload2.wsgi
def application(environ, start_response):
status = '200 OK'
output = str(sys.stderr)
print('STDERR %s' % __file__, file=sys.stderr)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
#<_io.TextIOWrapper encoding='utf-8'>
#[Mon Aug 17 19:12:23 2009] [error] STDERR /usr/httpd/www/appwsgi/wsgi/
upload2.wsgi
Ps did you read the other post about chunk transfer or was the
question not clear like this one ?
On Aug 17, 8:48 am, Graham Dumpleton <[email protected]>
wrote:
> Works fine for me on Python 3.0.1 and Python 3.1 with test program:
>
> import sys
>
> def application(environ, start_response):
> status = '200 OK'
> output = 'Hello World!'
>
> print('STDERR %s' % __file__, file=sys.stderr)
>
> response_headers = [('Content-type', 'text/plain'),
> ('Content-Length', str(len(output)))]
> start_response(status, response_headers)
>
> return [output]
>
> Try with a simple hello world program. If that doesn't work, change it to:
>
> import sys
>
> def application(environ, start_response):
> status = '200 OK'
> output = str(sys.stderr)
>
> print('STDERR %s' % __file__, file=sys.stderr)
>
> response_headers = [('Content-type', 'text/plain'),
> ('Content-Length', str(len(output)))]
> start_response(status, response_headers)
>
> return [output]
>
> and tell me what is displayed back in the browser.
>
> Graham
>
> 2009/8/17 Graham Dumpleton <[email protected]>:
>
> > 2009/8/17 gert <[email protected]>:
>
> >> I expected at least this message to show up in my log ?
>
> >> print('query=',query,file=sys.stderr)
> >> or some trace back where syntax is wrong ?
> >> I only get a 500, I usually get at least some sign about the thing i
> >> did wrong in the logs ?
>
> > Try:
>
> > print('query=',query,file=environ['wsgi.errors'])
>
> > If there is a problem I haven't seen, then that may work where the
> > other doesn't. If that doesn't work either, much deeper issue.
>
> > FWIW, I did change how logging worked for Python 3.X. In my tests on
> > MacOS X it was working with Python 3.1. I didn't try with Python 3.0,
> > so chance it doesn't work for that.
>
> > I'll look later when get a chance.
>
> > Graham
>
> >> On Aug 16, 11:17 pm, Graham Dumpleton <[email protected]>
> >> wrote:
> >>> 2009/8/16 gert <[email protected]>:
>
> >>> > this does not show any error messages in apache log ?
>
> >>> Is this noise, or are you pointing out a specific problem I need to
> >>> look at. If a problem, you need to explain what it is, I am not going
> >>> to try each of these examples to try and find out.
>
> >>> Graham
>
> >>> > [Sun Aug 16 14:57:12 2009] [info] [client 192.168.2.17] mod_wsgi
> >>> > (pid=5791, process='www', application=''): Loading WSGI script '/usr/
> >>> > httpd/www/appwsgi/wsgi/upload2.wsgi'.
>
> >>> > import os,sys
> >>> > def application(environ, response):
> >>> > #query=environ.get['QUERY_STRING']
> >>> > query=os.path.join(os.path.dirname(__file__),'teeeeeeeeeemp')
> >>> > print('query=',query,file=sys.stderr)
> >>> > range=environ.get('HTTP_RANGE','bytes=0-').replace
> >>> > ('bytes=','').split(',')
> >>> > offset=[]
> >>> > for r in range: offset.append(r.split('-'))
> >>> > with open(query,'wb') as f
> >>> > f.seek(offset[0][0])
> >>> > while True:
> >>> > chunk=environ['wsgi.input'].read(8192).decode('latin1')
> >>> > if not chunk: break
> >>> > f.write(chunk)
> >>> > l=os.fstat(f.fileno()).st_size
> >>> > response('200 OK', [('Content-Type', 'text/plain'), ('Content-
> >>> > Length', str(len(l)))])
> >>> > return [l]
>
> >>> > User www
> >>> > Group www
> >>> > Listen 80
> >>> > Listen 443
> >>> > ServerRoot "/usr/httpd"
> >>> > ServerAdmin [email protected]
> >>> > ServerName 192.168.2.17
> >>> > DocumentRoot "www"
> >>> > LogLevel info
> >>> > ErrorLog "logs/httpd.log"
> >>> > DefaultType text/plain
> >>> > AddDefaultCharset utf-8
>
> >>> > <Directory />
> >>> > Options ExecCGI Indexes FollowSymLinks
> >>> > Allow from all
> >>> > DirectoryIndex index.htm
> >>> > </Directory>
>
> >>> > LoadModule ssl_module modules/mod_ssl.so
> >>> > SSLSessionCache dbm:logs/ca
> >>> > SSLCertificateFile conf/ca.crt
> >>> > SSLCertificateKeyFile conf/ca.key
> >>> > SSLEngine off
>
> >>> > LoadModule wsgi_module modules/mod_wsgi.so
> >>> > WSGIDaemonProcess www python-path=/usr/httpd/www user=www group=www
> >>> > processes=1 threads=1 display-name="wsgi: www"
> >>> > WSGIProcessGroup www
> >>> > WSGIApplicationGroup %{GLOBAL}
> >>> > WSGIChunkedRequest On
> >>> > WSGILazyInitialization On
> >>> > WSGIRestrictEmbedded On
>
> >>> > LoadModule mime_module modules/mod_mime.so
> >>> > AddHandler wsgi-script .wsgi
> >>> > AddType text/css .css
> >>> > AddType text/javascript .js
> >>> > AddType application/xhtml+xml .htm
> >>> > AddType application/x-shockwave-flash .swf
> >>> > AddType video/x-flv .flv
> >>> > AddType audio/mpeg .mp3
> >>> > AddType image/png .png
> >>> > AddType image/x-icon .ico
>
> >>> > LoadModule deflate_module modules/mod_deflate.so
> >>> > AddOutputFilterByType DEFLATE text/html text/plain text/xml text/
> >>> > javascript text/css
>
> >>> > LoadModule authz_host_module modules/mod_authz_host.so
> >>> > LoadModule autoindex_module modules/mod_autoindex.so
> >>> > LoadModule dir_module modules/mod_dir.so
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---