Skip to content

Instantly share code, notes, and snippets.

@pop
Last active September 16, 2015 21:02
Show Gist options
  • Save pop/186aa98933ab41b413bd to your computer and use it in GitHub Desktop.
Save pop/186aa98933ab41b413bd to your computer and use it in GitHub Desktop.
A *very* simple flask app script for DevOps DayCamp 2015

Python Flask App

Thiiiis far above hello world.

Installation/Usage

$ sudo apt install git 
$ git clone $THISURL 
$ cd $DIRECTORYNAME
$ virtualenv $VIRTUALENVNAME
$ source $VIRTUALENVNAME/bin/activate
$ pip install -r requirements.txt   # installs the python dependencies
$ ./script.py   # Starts the webapp
* Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)

Open your browser to http://daycamp.osuosl.org:$YOURHTTPPORT

Woooo~ you did it, now we get to hacking!

Flask==0.10.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
Werkzeug==0.10.4
wheel==0.24.0
#!/usr/bin/env python
from flask import Flask, send_file
from datetime import datetime
app = Flask(__name__)
@app.route('/')
def hello():
now = datetime.now()
resp = ("<h1>You did it!</h1>"+
"<img src='/img'/>"+
"<p>Today's date is: "+now.strftime("%Y-%m-%d, %H:%M:%S"))
return resp
@app.route('/img')
def img():
return send_file('z.gif', mimetype='image/gif')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment