I would strongly recommend you start out with a WSGI framework such as Flask
rather than try and do things from scratch with WSGI. A framework like Flask
will do a lot of the hard work for you, especially around handling URL routing.
Doing things from scratch you will very quickly get into a mess if this is all
new to you.
So head over to:
http://flask.pocoo.org/ <http://flask.pocoo.org/>
and work through the Flask tutorial. Initially don't even use mod_wsgi, just
the Flask development server as you learn how to do things.
Once you get through that, if you really want to for some reason (although
still not recommended), drop back down to WSGI to do things from scratch to
learn more about low level details.
Graham
> On 31 Jan 2018, at 11:34 pm, Larry Cotton <[email protected]> wrote:
>
> Hi
>
> System Info:
>
> # cat /etc/redhat-release
> Red Hat Enterprise Linux Server release 6.4 (Santiago)
>
> # httpd -v
> Server version: Apache/2.4.25 (Unix)
> Server built: Jun 27 2017 16:23:25
>
> # python --version
> Python 2.7.11
>
> -------------------------------------------------
>
>
> I have set up apache + mod_wsgi and have done some playing with it to help
> get some understanding of how client and server interact.
>
> I am new to mod_wsgi and have not yet used it in anger, but the simple apps I
> have written seem to be working ok.
>
> However there is something I would like to understand regarding how the
> browser decides when to render a page.
>
> In the simple application below(tst1.wsgi) below I generate a simple html
> page that contains an image, logging the REQUEST_URI
> for each request.
>
> If, in the browser, I type the url <myserver>/wsgipractice/tst1/index the
> browser attempts to fully render the page and puts in a second request to get
> the image. The log output containing the REQUEST_URIs looks like:
> /wsgipractice/tst1/index
> /wsgipractice/tst1/images/myimage.jpg
>
> If, however, I type only the root url in the browser:
> <myserver>/wsgipractice/tst1 the browser does not seem to attempt to render
> the html page. No second request is put in to fetch the image. The log output
> containing the REQUEST_URIs looks like:
> /wsgipractice/tst1
>
> It does not seem to matter what comes after tst1 in the url (I can type in
> tst1/bob, or even simply terminate with separator: tst1/).
>
> Does anyone know what it is that triggers the browser to fully (or not)
> render a page ?
>
>
> tst1.wsgi
> ----------
> import os
>
> def get_page(environ, mime_type):
>
> html_str = \
> ('<html><body>'
> '<center><p style="font-weight:bold;">LARRY HOME</p></center>'
> '<div style="background-image: url(images/myimage.jpg)">'
> '<a href="http://google.com">' <http://google.com">'/>
> '<div>Home</div></a>'
> '</div>'
> '<br><p>Body</p><br></body></html>')
>
> return html_str, mime_type
>
> def application(environ, start_response):
>
> status = '200 OK'
>
> output = u''
>
> log_file = open(('/logs/tstpagegen.log'), 'a')
>
> log_file.write(environ['REQUEST_URI'] + '\n')
>
> log_file.close()
>
> output, mime_type = get_page(environ, 'text/html')
>
> response_headers = [('Content-type', mime_type),
> ('Content-Length', str(len(output)))]
>
> start_response(status, response_headers)
>
> return [output]
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi
> <https://groups.google.com/group/modwsgi>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.