Spaces:
Running
Running
import os | |
from flask import * | |
from flask_limiter import Limiter | |
from flask_limiter.util import get_remote_address | |
from routes.helpers import checkSignature | |
from routes import * | |
app = Flask(__name__) | |
app.config['JSON_AS_ASCII'] = False | |
limiter = Limiter(app=app, key_func=get_remote_address, default_limits=["5/minute"], storage_uri="memory://",) | |
#limiter | |
def ip_whitelist(): | |
try: | |
if request.method == 'POST': signature = request.form['signature'] | |
else: signature = request.args['signature'] | |
return checkSignature(request, signature) | |
except: return False | |
#error pages | |
def ratelimit_handler(e): return render_template('ratelimit.html') | |
def forbidden_handler(e): return render_template('forbidden.html') | |
def ratelimit_handler(e): return render_template('notfound.html') | |
# site routes | |
def index(): return render_template('index.html') | |
# sig gen | |
def signatureGen(): | |
return siteRoutes.signatureGen(request) | |
#empty routes | |
def emptyPath(): return {} | |
def emptyApiWA(path): return {"status": "error", "error_code": 100, "error_details": "No method like that found"} | |
#icon | |
def favicon(): return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon') | |
############### | |
#RECOGNIZE API | |
def recognizeVoice(): return witaiApi.recognizeVoice(request) | |
############### | |
#YT SOUND API | |
def search(): return ytApi.search(request) | |
def getFull(): return ytApi.getFull(request) | |
def getPreview(): return ytApi.getPreview(request) | |
############### | |
#OSU API | |
def findSong(): return osuApi.findSong(request) | |
def getBeatmap(): return osuApi.getBeatmap(request) | |
def getBMPreview(): return osuApi.getPreview(request) | |
def getBMFull(): return osuApi.getFull(request) | |
if __name__ == "__main__": | |
app.run(host="0.0.0.0", port=80, debug=True) | |