added minimal webinterface
This commit is contained in:
39
infomentor/templates/addlogin.html
Normal file
39
infomentor/templates/addlogin.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{% extends "bootstrap/base.html" %}
|
||||||
|
{% block title %}Infomentor Notifier{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<h1>Infomentor notifier</h1>
|
||||||
|
<form action="{{ url_for('create') }}" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="accesscode">AccessCode</label>
|
||||||
|
<input type="text" class="form-control" name="accesscode" id="accesscode" placeholder="Enter Accesscode">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">Username</label>
|
||||||
|
<input type="text" class="form-control" name="username" id="username" placeholder="Enter username">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" class="form-control" name="password" id="password" placeholder="Password">
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="notify" id="mail" value="mail" checked>
|
||||||
|
<label class="form-check-label" for="mail">
|
||||||
|
Mail
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="notify" id="pushover" value="pushover">
|
||||||
|
<label class="form-check-label" for="pushover">
|
||||||
|
Pushover
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="info">Mail/Pushover Id</label>
|
||||||
|
<input type="text" class="form-control" id="info" name="info" placeholder="Enter mail/pushover">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
8
infomentor/templates/notfound.html
Normal file
8
infomentor/templates/notfound.html
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Not Found</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Nothing here!
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
from infomentor import models, db
|
from infomentor import model, db
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, redirect, url_for, request
|
||||||
from flask_bootstrap import Bootstrap
|
from flask_bootstrap import Bootstrap
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -9,10 +9,30 @@ Bootstrap(app)
|
|||||||
def home():
|
def home():
|
||||||
return render_template('notfound.html')
|
return render_template('notfound.html')
|
||||||
|
|
||||||
@app.route('/addlogin/')
|
@app.route('/addlogin')
|
||||||
def extra():
|
def extra():
|
||||||
return render_template('addlogin.html')
|
return render_template('addlogin.html')
|
||||||
|
|
||||||
|
@app.route('/create', methods=['POST'])
|
||||||
|
def create():
|
||||||
|
if request.form['accesscode'] != 'fhKjzgV/BXWq4YRxUPO4qYlHWCDf':
|
||||||
|
return redirect(url_for('home'))
|
||||||
|
session = db.get_db()
|
||||||
|
username = request.form['username']
|
||||||
|
existing_user = session.query(model.User).filter(model.User.name == username).one_or_none()
|
||||||
|
if existing_user is not None:
|
||||||
|
return redirect(url_for('home'))
|
||||||
|
|
||||||
|
password = request.form['password']
|
||||||
|
user = model.User(name=username, password=password)
|
||||||
|
if request.form['notify'] == 'mail':
|
||||||
|
user.notification = [model.Notification(ntype=model.Notification.Types.EMAIL, info=request.form['info'])]
|
||||||
|
else:
|
||||||
|
user.notification = [model.Notification(ntype=model.Notification.Types.PUSHOVER, info=request.form['info'])]
|
||||||
|
session.add(user)
|
||||||
|
session.commit()
|
||||||
|
return "success"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -8,5 +8,5 @@ setup(
|
|||||||
author_email = 'matthias@bilger.info',
|
author_email = 'matthias@bilger.info',
|
||||||
description = 'grab infomentor news and push or mail them',
|
description = 'grab infomentor news and push or mail them',
|
||||||
packages = find_packages(),
|
packages = find_packages(),
|
||||||
install_requires = ['pycrypto', 'request', 'sqlalchemy', 'dateparser', 'python-pushover' ],
|
install_requires = ['pycrypto', 'request', 'sqlalchemy', 'dateparser', 'python-pushover', 'flask', 'flask-bootstrap' ],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user