Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

show statistics on /

  • Loading branch information...
commit b5491d6e6386e966e70bda72c023616249812310 1 parent 14aeeac
@posativ authored
View
9 regenwolken/manage.py
@@ -19,14 +19,7 @@
from gridfs import GridFS
from gridfs.errors import NoFile
-
-def ppsize(num):
- '''pretty-print filesize.
- http://blogmag.net/blog/read/38/Print_human_readable_file_size'''
- for x in ['bytes','KiB','MiB','GiB','TB']:
- if num < 1024.0:
- return "%3.2f %s" % (num, x)
- num /= 1024.0
+from regenwolken.utils import ppsize
def tdelta(input):
View
BIN  regenwolken/static/images/regenwolken.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
24 regenwolken/templates/index.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Regenwolken: open source, self-hosting CloudApp</title>
+</head>
+<body>
+
+<section style="margin: 0 auto; width: 800px;">
+<img src="/static/images/regenwolken.png" />
+
+<ul style="list-style-type: none;">
+ <li>Users: {{ users }}</li>
+ <li>Files: {{ files }}</li>
+ <li>Size : {{ size }}</li>
+ <li>Hits : {{ hits }}</li>
+</ul>
+<p>– <a href="https://github.com/posativ/regenwolken#readme">See
+Instructions on GitHub</a>.</p>
+
+</section>
+
+</body>
+
+</html>
View
9 regenwolken/utils.py
@@ -189,3 +189,12 @@ class Struct:
"""dict -> class, http://stackoverflow.com/questions/1305532/convert-python-dict-to-object"""
def __init__(self, **entries):
self.__dict__.update(entries)
+
+
+def ppsize(num):
+ '''pretty-print filesize.
+ http://blogmag.net/blog/read/38/Print_human_readable_file_size'''
+ for x in ['bytes','KiB','MiB','GiB','TB']:
+ if num < 1024.0:
+ return "%3.2f %s" % (num, x)
+ num /= 1024.0
View
20 regenwolken/views.py
@@ -14,7 +14,7 @@
from pymongo import DESCENDING
from flask import request, abort, jsonify, json, current_app, render_template, redirect
-from regenwolken.utils import login, private, A1, slug, thumbnail, clear, urlscheme
+from regenwolken.utils import login, private, A1, slug, thumbnail, clear, urlscheme, ppsize
from regenwolken.specs import Item, Account, Drop
@@ -23,16 +23,16 @@ def index():
-- http://developer.getcloudapp.com/upload-file"""
+ db, fs = current_app.db, current_app.fs
+ config, sessions = current_app.config, current_app.sessions
+
if request.method == 'POST' and not request.accept_mimetypes.accept_html:
try:
- account = current_app.sessions.pop(request.form.get('key'))['account']
+ account = sessions.pop(request.form.get('key'))['account']
except KeyError:
abort(401)
- db, fs = current_app.db, current_app.fs
- config, sessions = current_app.config, current_app.sessions
-
acc = db.accounts.find_one({'email': account})
source = request.headers.get('User-Agent', 'Regenschirm++/1.0').split(' ', 1)[0]
privacy = request.form.get('acl', acc['private_items'])
@@ -50,11 +50,11 @@ def index():
else:
return jsonify(Item(obj, config, urlscheme(request)))
else:
- return Response(status=501, content_type='text/html', response=(
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
- '<title>501 Not Implemented</title>'
- '<h1>Nope. Web Interface still not implemented.</h1>'
- '<p>The server does not support the action requested by the browser.</p>'))
+ users = db.accounts.find().count()
+ files = fs.gfs._GridFS__files.count()
+ size = ppsize(sum([f['length'] for f in fs.gfs._GridFS__files.find()]))
+ hits = sum([f['view_counter'] for f in fs.mdb.find()])
+ return Response(render_template("index.html", **locals()), 200, content_type="text/html")
@login
Please sign in to comment.
Something went wrong with that request. Please try again.