Unverified Commit 1adb6e57 authored by giskard's avatar giskard
Browse files

Flask implementation

parent ad0ec147
#!/usr/bin/env python
from nospam import api
from nospam import instrumentation
from flask import Flask, render_template, url_for
from flaskext.xmlrpc import XMLRPCHandler, Fault
app = Flask(__name__, )
config = {'port': 9001,
'spam_threshold': '2.0',
'data_dir': './var/lib/nospam',
'config_dir': './config'}
ns = api.NoSpam(config)
blogspam_api = XMLRPCHandler("", instance=api.BlogSpamCompatibleAPI(ns))
blogspam_api.connect(app, '/RPC2')
# blogspam_api.connect(app, '/')
def docs(doc):
# TODO: grrrrr
if not doc.endswith('.html'):
doc = doc + '.html'
docfile = 'docs/' + doc
return render_template(docfile)
def get_vars():
return instrumentation.get_vars()
def homepage():
n_ham, n_spam = ns.stats()
seen_comments = n_ham + n_spam
if seen_comments > 0:
pct_spam = 100.0 * n_spam / seen_comments
pct_spam = 0
return render_template( 'index.html', seen_comments=seen_comments,
pct_spam=pct_spam, num_ham=n_ham, num_spam=n_spam)
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment