add gunicorn support

This commit is contained in:
makefu 2013-11-19 09:43:35 +01:00
parent 8a0f30785a
commit 1521fa463e
3 changed files with 11 additions and 8 deletions

View file

@ -14,4 +14,4 @@ It is written as a replacement for the gorgeous sprunge.us
. bin/activate . bin/activate
cd bump cd bump
python init.py gunicorn -b 127.0.0.1:4000 init:app

View file

@ -1,11 +1,10 @@
from flask import Flask, Response, request, send_from_directory from flask import Flask, Response, request, send_from_directory
from functools import wraps from functools import wraps
import sys
import random import random
import string import string
import os import os
app = Flask(__name__) app = Flask(__name__)
storedir = os.path.join(app.root_path, 'store'), storedir = os.path.join(app.root_path, 'store')
app.config['storedir'] = storedir app.config['storedir'] = storedir
@ -25,10 +24,13 @@ def usage(host):
< balls < balls
Source at http://github.com/makefu/bump""".format(host) Source at http://github.com/makefu/bump""".format(host)
@app.route('/favicon.ico') @app.route('/favicon.ico')
def favicon(): def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'), return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon') 'favicon.ico',
mimetype='image/vnd.microsoft.icon')
@returns_plain @returns_plain
@app.route("/", methods=["GET"]) @app.route("/", methods=["GET"])
@ -63,11 +65,11 @@ def retrieve_file(key):
def store(key, value): def store(key, value):
with open("%s/%s" % (storedir, key), "wb+") as f: with open("%s/%s" % (storedir, key), "wb+") as f:
try: try:
# py3 # py3
f.write(bytes(value, "UTF-8")) f.write(bytes(value, "UTF-8"))
except: except:
# py2 # py2
f.write(value) f.write(value)
def retrieve(key): def retrieve(key):

View file

@ -3,4 +3,5 @@ Jinja2==2.7.1
MarkupSafe==0.18 MarkupSafe==0.18
Werkzeug==0.9.4 Werkzeug==0.9.4
distribute==0.6.31 distribute==0.6.31
gunicorn==18.0
itsdangerous==0.23 itsdangerous==0.23