From 1d2b54d55b786cb3ce77b19afb0324534a9e2e76 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Mon, 20 May 2019 21:37:57 +0200 Subject: [PATCH] Hello world, whatever --- .gitignore | 3 +++ app.py | 45 ++++++++++++++++++++++++++++++++++++++++++++ templates/index.html | 6 ++++++ 3 files changed, 54 insertions(+) create mode 100644 .gitignore create mode 100644 app.py create mode 100644 templates/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ec74ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.py[co] +.ropeproject +__pycache__ diff --git a/app.py b/app.py new file mode 100644 index 0000000..2098897 --- /dev/null +++ b/app.py @@ -0,0 +1,45 @@ +from flask import Flask, render_template +from flask_admin import Admin +from flask_sqlalchemy import SQLAlchemy +from flask_admin.contrib.sqla import ModelView + +import requests + + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'changeme' +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/database.db' + +db = SQLAlchemy(app) +admin = Admin(app, name='microblog', template_mode='bootstrap3') + + +class Site(db.Model): + __tablename__ = 'sites' + + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String) + api_key = db.Column(db.String) + network_id = db.Column(db.String) + + +admin.add_view(ModelView(Site, db.session)) + + +@app.route('/') +def index(): + return render_template('index.html', sites=Site.query.all()) + + +@app.route('/fix/') +def fix_firewall(site_id): + site = Site.query.get(site_id) + resp = requests.get('https://kasownik.hackerspace.pl/api/judgement/%s.json' % (site.api_key,)) + + return resp.json()['status'] + + +@app.route('/break/') +def break_firewall(site_id): + return site_id diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..77f4536 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,6 @@ +{% for site in sites %} +

{{ site.name }}

+ {{ site.api_key }} + Fix firewall + Break firewall +{% endfor %}