2017-03-12 18:55:05 +00:00
|
|
|
import flask
|
|
|
|
from flask import request
|
|
|
|
|
2017-04-06 22:25:47 +00:00
|
|
|
from backends import PowerDNSBackend
|
2017-03-12 18:55:05 +00:00
|
|
|
from utils import verify_token
|
|
|
|
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
app.config.from_pyfile('config.cfg')
|
|
|
|
|
2017-04-06 22:25:47 +00:00
|
|
|
app.backend = PowerDNSBackend(app.config)
|
2017-03-12 18:55:05 +00:00
|
|
|
|
|
|
|
@app.route('/api/1/add')
|
|
|
|
@verify_token
|
|
|
|
def add():
|
2017-04-06 22:25:47 +00:00
|
|
|
name, type_ = request.args['record'].rsplit(':', 1)
|
|
|
|
app.backend.add(name, request.args['value'], type_)
|
2017-03-12 18:55:05 +00:00
|
|
|
return 'ok'
|
|
|
|
|
2017-04-06 22:25:47 +00:00
|
|
|
@app.route('/api/1/delete')
|
2017-03-12 18:55:05 +00:00
|
|
|
@verify_token
|
2017-04-06 22:25:47 +00:00
|
|
|
def delete():
|
|
|
|
name, type_ = request.args['record'].rsplit(':', 1)
|
|
|
|
app.backend.delete(name, type_)
|
2017-03-12 18:55:05 +00:00
|
|
|
return 'ok'
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app.run(debug=True)
|