Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic handling of poller registration
- Loading branch information
1 parent
b2dc741
commit b99d6e7
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from flask import Blueprint, render_template | ||
from flask import Blueprint, render_template, jsonify, request | ||
from libs.pollers import Poller | ||
|
||
mod_pollers = Blueprint('pollers', __name__, url_prefix='/pollers') | ||
|
||
pollers = [] | ||
|
||
|
||
@mod_pollers.route('/', methods=['GET']) | ||
def home(): | ||
return render_template('pollers/pollers.html') | ||
def get_pollers(): | ||
return render_template('pollers/pollers.html', pollers=pollers) | ||
|
||
|
||
@mod_pollers.route('/register', methods=['POST']) | ||
def register(): | ||
if not request.json: | ||
print('hit') | ||
return render_template('pollers/pollers.html', pollers=pollers) | ||
|
||
poller = Poller(request.json['ip'], | ||
request.json['port'], | ||
request.json['name']) | ||
pollers.append(poller) | ||
return jsonify({'status': 'poller created'}), 201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters