The code is
import web
web.config.debug = False
urls = (
"/count", "count"
"/reset", "reset"
)
app = web.application(urls, locals())
store = web.session.DiskStore('sessions')
session = web.session.Session(app, store, initialzer = {'count': 0})
class count:
def GET(self):
session.count += 1
return str(session.count)
class reset:
def GET(self):
session.kill()
return ""
if __name__ == "__main__":
app.run()
and according to the context, it says "To make this work, you need to create a sessions/ directory where the application can put session storage. Do that, run this application, and go to /count. Hit refresh and watch the counter go up. Close the browser and it forgets who you are, which is what we want for the game. There's a way to make the browser remember forever, but that makes testing and development harder. If you then go to /reset and back to /count, you can see your counter reset because you've killed the session."
I tried to go to the address http://localhost:8080 but it says ""HTTP/1.1 GET /favicon.ico" - 500 Internal Server Error".
Try to access http://localhost:8080/count to get the count, and then http://localhost:8080/reset to reset it. This should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.