Forums

Scheduled Task output to public URL

Next in my project I'm looking to generate an image, daily, and then post that image to a URL so it can be viewed.

I believe the process is as follows so I thought I'd confirm that here and get any tips.

  1. set up scheduled task script, running once a day (or more if my requirements change)
  2. set up a web app, even though I don't have an app per se (use manual config?), the web app allows me to set a Static File directory.
  3. then publish the images to that static file directory
  4. Bobs your uncle!

At the public URL, I just want the static files I post. So I likely need to remove any pages/code that Manual Config set up.

Does this sound right?

Yup, that should work fine! The only thing I'd change there is your last point about removing any pages or code that manual config sets up -- the only file it sets up will be a placeholder WSGI file, which is necessary for your site to work at all. However, it should be pretty easy to change so that the page at the "top" level of your site is just a 404 not found.

Thanks for the confirmation. I'm recently set it up and so far working. I've not removed the default hello page yet, but will do that and just leave/set up 404 as you suggest.

To save you some time -- this is what a "404 for everything" WSGI file looks like:

def application(environ, start_response):
    status = '404 NOT FOUND'
    content = 'Page not found.'
    response_headers = [('Content-Type', 'text/html'), ('Content-Length', str(len(content)))]
    start_response(status, response_headers)
    yield content.encode('utf8')

Thank you.