38 lines
913 B
Python
38 lines
913 B
Python
from flask import render_template, request, jsonify, send_from_directory
|
|
from www import app
|
|
import logging
|
|
from www import archive
|
|
|
|
|
|
@app.route('/')
|
|
def index():
|
|
l = archive.lists()
|
|
return render_template("index.html", lists=l, tags=archive.tags())
|
|
|
|
@app.route('/tags')
|
|
def tags():
|
|
return jsonify(result=archive.tags())
|
|
|
|
@app.route('/report')
|
|
def report():
|
|
return jsonify(report=archive.report())
|
|
|
|
# @app.route('/favicon.ico')
|
|
# def favicon():
|
|
# return send_from_directory(os.path.join(app.root_path, 'static'),
|
|
# 'favicon.ico', mimetype='image/vnd.microsoft.icon')
|
|
|
|
@app.route('/collect')
|
|
def collect():
|
|
url = request.args.get('url')
|
|
tag = request.args.get('tags')
|
|
li = request.args.get('list')
|
|
|
|
msg = "Added " + url + " to " + tag
|
|
if not archive.commit(li, url, tag):
|
|
msg = url + " already exists..."
|
|
|
|
return jsonify({ "msg": msg, "report": archive.report()})
|
|
|
|
|