Example #1
0
import docker
from flask import Flask, render_template, session, g, redirect
from flask.ext.bootstrap import Bootstrap

import psutil
import requests

from flask.ext.openid import OpenID
import sqlite3dbm

app = Flask(__name__)
app.secret_key = "arglebargle"
oid = OpenID(app, os.path.join(os.path.dirname(__file__), "openid_store"))

app.config["BOOTSTRAP_USE_MINIFIED"] = True
app.config["BOOTSTRAP_USE_CDN"] = True
app.config["BOOTSTRAP_FONTAWESOME"] = True
app.config["SECRET_KEY"] = "devkey"

CONTAINER_STORAGE = "/usr/local/etc/jiffylab/webapp/containers.json"
SERVICES_HOST = "127.0.0.1"
BASE_IMAGE = "ytproject/yt-devel"
BASE_IMAGE_TAG = "jiffylab"

# or can use available for vm
initial_memory_budget = psutil.virtual_memory().free

# how much memory should each container be limited to, in k.
CONTAINER_MEM_LIMIT = 1024 * 1024 * 128
# how much memory must remain in order for a new container to start?
MEM_MIN = CONTAINER_MEM_LIMIT + 1024 * 1024 * 128
Example #2
0
#!/usr/bin/env python
# coding=utf8

import os
from flask import Flask, render_template, request
from flask.ext.bootstrap import Bootstrap
import useragent

app = Flask(__name__)
Bootstrap(app)

app.config["BOOTSTRAP_USE_MINIFIED"] = True
app.config["BOOTSTRAP_USE_CDN"] = False
app.config["BOOTSTRAP_FONTAWESOME"] = True
app.config["BOOTSTRAP_GOOGLE_ANALYTICS_ACCOUNT"] = "UA-36835748-1"


@app.route("/")
def index():
    ua = useragent.detect(str(request.user_agent))
    os = detectOS(ua)
    return render_template("index.html")


@app.route("/about/")
def about():
    return render_template("about.html")


def detectOS(ua):
    os_string = ua.os.family.lower()