Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Do `echo 0 > ~/visits.txt` before serving
  3.  
  4. with open('../../visits.txt', 'r+') as f:
  5. visits = int(f.read()) + 1 # Read visit count, increment
  6. f.seek(0)
  7. f.write(str(visits)) # Save visit count
  8.  
  9. # Write response!
  10. print('Content-Type: text/plain')
  11. print('Cache-Control: no-cache')
  12. print()
  13. print(visits)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement