TorrentIndexer/indexer.py

54 lines
1.3 KiB
Python
Raw Normal View History

2015-02-05 01:02:32 +01:00
#!/usr/bin/python3
# vim:ts=2 sw=2 sts=2 noexpandtab
import json, os
2015-02-06 22:03:42 +01:00
from flask import Flask, render_template, url_for, request
from werkzeug import secure_filename
uploadFolder = "upload"
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = uploadFolder
strings = None
settings = None
2015-02-05 01:02:32 +01:00
@app.route("/")
def index():
return render_template("search.html", strings=strings)
@app.route("/categories")
def categorys():
return render_template("categories.html", strings=strings)
@app.route("/create")
def create():
return render_template("create.html", categories=settings["categories"], strings=strings)
2015-02-06 22:03:42 +01:00
@app.route("/search", methods=['GET'])
def search():
return render_template("result.html", results=request.args.get("q", ""), strings=strings)
def getLocalString(language, descriptor):
if language in strings.keys():
if descriptor in strings[language].keys():
return strings[language][descriptor]
else:
return None
else:
return None
def init():
global strings
global settings
with open("strings.json", "r") as strings:
strings = json.load(strings)
with open("settings.json", "r") as settings:
settings = json.load(settings)
2015-02-06 22:03:42 +01:00
if __name__ == "__main__":
app.jinja_env.globals.update(getLocalString=getLocalString)
app.jinja_env.globals.update(json=json)
init()
print(settings["categories"].keys())
app.run(debug=True)