From df2e425b346b95c6493a684025374b956349a0da Mon Sep 17 00:00:00 2001 From: Roberto Hueso Gómez Date: Mon, 31 Aug 2020 11:55:19 +0200 Subject: Add basic backend structure This adds views functions and ogServer config loading. --- ogcp/__init__.py | 6 ++++++ ogcp/cfg/ogserver.json | 5 +++++ ogcp/og_server.py | 15 +++++++++++++++ ogcp/views.py | 17 +++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 ogcp/__init__.py create mode 100644 ogcp/cfg/ogserver.json create mode 100644 ogcp/og_server.py create mode 100644 ogcp/views.py (limited to 'ogcp') diff --git a/ogcp/__init__.py b/ogcp/__init__.py new file mode 100644 index 0000000..1fda3f1 --- /dev/null +++ b/ogcp/__init__.py @@ -0,0 +1,6 @@ +from flask_babel import Babel +from flask import Flask +app = Flask(__name__) +babel = Babel(app) + +import ogcp.views diff --git a/ogcp/cfg/ogserver.json b/ogcp/cfg/ogserver.json new file mode 100644 index 0000000..a066595 --- /dev/null +++ b/ogcp/cfg/ogserver.json @@ -0,0 +1,5 @@ +{ + "ip": "127.0.0.1", + "port": 8888, + "api_token": "c3fe7bb0395747ec42a25df027585871" +} diff --git a/ogcp/og_server.py b/ogcp/og_server.py new file mode 100644 index 0000000..6242f02 --- /dev/null +++ b/ogcp/og_server.py @@ -0,0 +1,15 @@ +import json + +class OGServer: + def __init__(self, ip='127.0.0.1', port=8888, api_token=""): + self.ip = ip + self.port = port + self.api_token = api_token + + def load_config(self, path): + with open(path, 'r') as f: + cfg = json.load(f) + + self.ip = cfg['ip'] + self.port = cfg['port'] + self.api_token = cfg['api_token'] diff --git a/ogcp/views.py b/ogcp/views.py new file mode 100644 index 0000000..4b03d2d --- /dev/null +++ b/ogcp/views.py @@ -0,0 +1,17 @@ +from flask import g, render_template, url_for +from ogcp.og_server import OGServer +from flask_babel import _ +from ogcp import app + +@app.before_request +def load_config(): + g.server = OGServer() + g.server.load_config('ogcp/cfg/ogserver.json') + +@app.route('/') +def index(): + return render_template('base.html') + +@app.route('/scopes/') +def scopes(): + return render_template('base.html') -- cgit v1.2.3-18-g5258