osu-wayback/web.py
2018-05-31 10:59:10 +02:00

40 lines
918 B
Python

import json
import MySQLdb
import MySQLdb.cursors
from flask import Flask, make_response, request, render_template, jsonify
from handlers import update, file
from objects import glob
app = Flask(__name__)
with open("config.json", "r") as f:
config = json.load(f)
# Setup sql
glob.sql = MySQLdb.connect(**config["sql"], cursorclass = MySQLdb.cursors.DictCursor)
@app.route("/")
@app.route("/home")
def home_index():
return render_template("index.html")
@app.route("/download")
def download_index():
return render_template("download.html")
@app.route("/api")
def api_index():
return render_template("api.html")
@app.route("/api/getUpdate", methods=["GET", "POST"])
def api_update():
data = update.handle(request)
return jsonify(data)
@app.route("/api/getFile", methods=["GET", "POST"])
def api_file():
data = file.handle(request)
return jsonify(data)
if __name__ == "__main__":
app.run(**config["web"])