mirror of
https://github.com/r4sas/Niflheim-api
synced 2025-01-12 07:58:00 +00:00
added flask-limiter
prevent abuse
This commit is contained in:
parent
8b5b750c32
commit
9a8724756c
@ -2,7 +2,10 @@ from flask import Flask, request
|
||||
from flask_restful import Resource, Api
|
||||
from sqlalchemy import create_engine
|
||||
from json import dumps
|
||||
#rate limiting support
|
||||
from flask.ext.jsonpify import jsonify
|
||||
from flask_limiter import Limiter
|
||||
from flask_limiter.util import get_remote_address
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
@ -17,6 +20,12 @@ db_connect = create_engine('sqlite:///' + db_path)
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
limiter = Limiter(
|
||||
app,
|
||||
key_func=get_remote_address,
|
||||
default_limits=["500/day", "60/hour"]
|
||||
)
|
||||
|
||||
#quickly figure out which is old or new
|
||||
def age_calc(ustamp):
|
||||
if (time.time() - ustamp) <= 14400 :
|
||||
|
Loading…
Reference in New Issue
Block a user