// `response` is an instance of System.Net.Http.HttpResponseMessageresponse.Headers.CacheControl = new CacheControlHeaderValue{NoCache = true,NoStore = true,MustRevalidate = true};response.Headers.Pragma.ParseAdd("no-cache");// We can't use `response.Content.Headers.Expires` directly// since it allows only `DateTimeOffset?` values.response.Content?.Headers.TryAddWithoutValidation("Expires", 0.ToString());
import webimport sysimport PERSONAL-UTILITIES
myname = "main.py"
urls = ('/', 'main_class')
main = web.application(urls, globals())
render = web.template.render("templates/", base="layout", cache=False)
class main_class(object):def GET(self):web.header("Cache-control","no-cache, no-store, must-revalidate")web.header("Pragma", "no-cache")web.header("Expires", "0")return render.main_form()
def POST(self):msg = "POSTed:"form = web.input(function = None)web.header("Cache-control","no-cache, no-store, must-revalidate")web.header("Pragma", "no-cache")web.header("Expires", "0")return render.index_laid_out(greeting = msg + form.function)
if __name__ == "__main__":nargs = len(sys.argv)# Ensure that there are enough arguments after python program nameif nargs != 2:LOG-AND-DIE("%s: Command line error, nargs=%s, should be 2", myname, nargs)# Make sure that the TCP port number is numerictry:tcp_port = int(sys.argv[1])except Exception as e:LOG-AND-DIE ("%s: tcp_port = int(%s) failed (not an integer)", myname, sys.argv[1])# All is well!JUST-LOG("%s: Running on port %d", myname, tcp_port)web.httpserver.runsimple(main.wsgifunc(), ("localhost", tcp_port))main.run()