commit 70110db2ef73f150ca9f8d9a043157cd39b41fb4 Author: wes Date: Mon Sep 26 00:08:00 2016 -0400 first commit diff --git a/appconfig b/appconfig new file mode 100644 index 0000000..82d0579 --- /dev/null +++ b/appconfig @@ -0,0 +1 @@ +SERVER_NAME="NAME_HERE" diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..cb9e542 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,46 @@ +{% extends "bootstrap/base.html" %} + +{% block head %} + {{super()}} + + +{% endblock %} + + + + {% block content %} + + + + {% endblock %} + + + +{% block styles %} + + {{super()}} + + + +{% endblock %} + +{% block scripts %} + {{super()}} + + + +{% endblock %} + + + diff --git a/website.py b/website.py new file mode 100755 index 0000000..e6f4245 --- /dev/null +++ b/website.py @@ -0,0 +1,62 @@ +#! /usr/bin/python2 +from functools import partial + +from flask import Blueprint, abort, Flask, render_template, flash, request, send_from_directory +from flask_bootstrap import Bootstrap +from flask_appconfig import AppConfig + +from urllib import unquote + +from urllib import quote, unquote +from json import dumps, loads + +from werkzeug.contrib.cache import MemcachedCache +cache = MemcachedCache(['127.0.0.1:11211']) + +import os + +def cacheit(key, thunk): + """ + Tries to find a cached version of ``key'' + If there is no cached version then it will + evaluate thunk (which must be a generator) + and cache that, then return the result + """ + cached = cache.get(quote(key)) + if cached is None: + result = list(thunk()) + cache.set(quote(key), result) + return result + return cached + +def NeverWhere(configfile=None): + blueprint = Blueprint("NeverWhere",__name__, template_folder="templates") + + @blueprint.route('/favicon.ico') + #def favicon(): + #return send_from_directory("/srv/http/goal/favicon.ico", + #'favicon.ico', mimetype='image/vnd.microsoft.icon') + + @blueprint.route("/", methods=("GET", "POST")) + def index(): + return render_template("index.html") + + @blueprint.route("./scripts/") + def send_script(filename): + return send_from_directory(app.config["scripts"], filename) + + @blueprint.route("./styles/") + def send_style(filename): + return send_from_directory(app.config["styles"], filename) + + app = Flask(__name__) + app.register_blueprint(blueprint, url_prefix="/") + Bootstrap(app) + app.config["scripts"] = "./scripts" + app.config["styles"] = "./styles" + return app + +app = NeverWhere() + +if __name__ == "__main__": + NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True)