Instantly share code, notes, and snippets.

@yne /
Created Mar 12, 2017

What would you like to do?
Google AppEngine most recent visitor page
#!/usr/bin/env python
from flask import Flask
from flask import request
from datetime import datetime
app = Flask(__name__)
#app.config['DEBUG'] = True
from google.appengine.ext import ndb
class Client(ndb.Model):
addr = ndb.StringProperty(indexed=True)
date = ndb.DateTimeProperty(auto_now=True)
def hello():
Client.get_or_insert(request.remote_addr, addr=request.remote_addr).put()
return "\n".join(map(lambda c:"%s %i"%(c.addr, (, clients)), 200, {'Content-Type': 'text/plain'}
def flush():
return "%r"%ndb.delete_multi(Client.query().fetch(keys_only=True))
def page_not_found(e):
return 'Sorry, nothing at this URL.', 404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment