Skip to content

Instantly share code, notes, and snippets.

@josephdunn
Created August 7, 2013 20:34
Show Gist options
  • Save josephdunn/6178368 to your computer and use it in GitHub Desktop.
Save josephdunn/6178368 to your computer and use it in GitHub Desktop.
import time
import random
import datetime
from flask import Flask
# app
app = Flask(__name__)
app.config.from_pyfile('config.py')
# views
@app.route('/')
def index():
gotReqTime = datetime.datetime.now()
willSleep = random.randint(1, 10)
time.sleep(willSleep)
nowTime = datetime.datetime.now()
return 'Foo! I got a request at ' + str(gotReqTime) + ', then slept ' + str(willSleep) + ' seconds. It is now ' + str(nowTime)
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment