diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..67dd241 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python +COPY ./certs /certs + +COPY ./ /app +RUN pip install -r /app/requirements.txt + +CMD python /app/run.py \ No newline at end of file diff --git a/README.md b/README.md index 8dc9425..4ba031d 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ BioSys + + + +# Notes + +FingerprintID: 0 is the left pinky 9 is the right pinky, people with more than 10 fingers may use another system. \ No newline at end of file diff --git a/__pycache__/db.cpython-37.pyc b/__pycache__/db.cpython-37.pyc new file mode 100644 index 0000000..b2d88c3 Binary files /dev/null and b/__pycache__/db.cpython-37.pyc differ diff --git a/__pycache__/run.cpython-37.pyc b/__pycache__/run.cpython-37.pyc new file mode 100644 index 0000000..4f94664 Binary files /dev/null and b/__pycache__/run.cpython-37.pyc differ diff --git a/application/__init__.py b/application/__init__.py new file mode 100644 index 0000000..da900d0 --- /dev/null +++ b/application/__init__.py @@ -0,0 +1,21 @@ +from flask import Flask, request, g, render_template +from flask_restful import Resource, reqparse +from flask_restful_swagger_3 import Api +from flask_cors import CORS +import os +from json import dumps +import application.endpoints as endpoints +import application.config as config +from flask_sqlalchemy import SQLAlchemy + +app = Flask(__name__) +api = Api(app, version='1', contact={"name":""}, license={"name":"Online Dienst Dokumentation"}, api_spec_url='/api/swagger') + + +api.add_resource(endpoints.PersonList,'/api/v1/person/') + +@app.route("/") +def index(): + """serve the ui""" + return render_template("index.html") + \ No newline at end of file diff --git a/application/__pycache__/__init__.cpython-37.pyc b/application/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..a4c0100 Binary files /dev/null and b/application/__pycache__/__init__.cpython-37.pyc differ diff --git a/application/__pycache__/app.cpython-37.pyc b/application/__pycache__/app.cpython-37.pyc new file mode 100644 index 0000000..eb08c4c Binary files /dev/null and b/application/__pycache__/app.cpython-37.pyc differ diff --git a/application/__pycache__/config.cpython-37.pyc b/application/__pycache__/config.cpython-37.pyc new file mode 100644 index 0000000..488e64a Binary files /dev/null and b/application/__pycache__/config.cpython-37.pyc differ diff --git a/application/__pycache__/db.cpython-37.pyc b/application/__pycache__/db.cpython-37.pyc new file mode 100644 index 0000000..ba30309 Binary files /dev/null and b/application/__pycache__/db.cpython-37.pyc differ diff --git a/application/__pycache__/endpoints.cpython-37.pyc b/application/__pycache__/endpoints.cpython-37.pyc new file mode 100644 index 0000000..52361da Binary files /dev/null and b/application/__pycache__/endpoints.cpython-37.pyc differ diff --git a/application/config.py b/application/config.py new file mode 100644 index 0000000..6c2c8da --- /dev/null +++ b/application/config.py @@ -0,0 +1,2 @@ + +debug = True diff --git a/application/db.py b/application/db.py new file mode 100644 index 0000000..08a616b --- /dev/null +++ b/application/db.py @@ -0,0 +1,39 @@ +import sqlalchemy as db +from sqlalchemy import Column, String, Integer, Numeric, Table, DateTime, ARRAY, ForeignKey, create_engine, LargeBinary, Enum +from sqlalchemy.orm import sessionmaker, relationship, column_property +from datetime import datetime +from sqlalchemy.ext.declarative import declarative_base +import enum +from flask_sqlalchemy import SQLAlchemy +from flask import Flask + +engine = db.create_engine('sqlite:///./test.sqlite', echo=True) +connection = engine.connect() +Base = declarative_base() +Session = sessionmaker(bind=engine) + +class Gender(enum.Enum): + other = "other" + male = "male" + female = "female" + +class Person(Base): + __tablename__ = "person" + person_id = Column('person_id', Integer, primary_key=True, autoincrement=True) + timestamp = Column('timestamp', DateTime, default=datetime.utcnow) + fname = Column('fname', String(50)) + lname = Column('lname', String(50)) + yob = Column('yob', Integer) + gender = Column('gender', Enum(Gender)) + face = Column('face', LargeBinary) + fingerprints = relationship("Fingerprint", foreign_keys='Fingerprint.person_id') + +class Fingerprint(Base): + __tablename__ = "fingerprint" + person_id = Column('person_id', Integer, ForeignKey('person.person_id'), primary_key=True) + + fingerprint_id = Column('fingerprint_id', Integer, primary_key=True) # 0: left pinky; 9: right pinky + timestamp = Column('timestamp', DateTime, default=datetime.utcnow) + fingerprint = Column('fingerprint', LargeBinary) + +Base.metadata.create_all(engine) \ No newline at end of file diff --git a/application/endpoints.py b/application/endpoints.py new file mode 100644 index 0000000..a78322f --- /dev/null +++ b/application/endpoints.py @@ -0,0 +1,54 @@ +from flask_restful import Resource, reqparse +import flask +import requests +import application.config as config +import json +from application.db import Session, Person + +class PersonList(Resource): + def post(self, id): + """ """ + try: + data = "" + return flask.make_response(flask.jsonify({'data': data}), 201) + except Exception as e: + print("error: -", e) + return flask.make_response(flask.jsonify({'error': str(e)}), 400) + + def get(self, id): + """ """ + try: + session = Session() + person = Person(fname="hi") + session.add(person) + session.commit() + + data = list(session.query(Person).all()) + arr = [] + for x in data: + arr.append(json.loads(x)) + + print(arr) + return flask.make_response(flask.jsonify({'data': arr}), 200) + except Exception as e: + print("error: -", e) + return flask.make_response(flask.jsonify({'error': str(e)}), 400) + + def put(self, id): + """ """ + try: + data = "" + return flask.make_response(flask.jsonify({'data': data}), 200) + except Exception as e: + print("error: -", e) + return flask.make_response(flask.jsonify({'error': str(e)}), 400) + + def delete(self, id): + """ """ + try: + data = "" + return flask.make_response(flask.jsonify({'data': data}), 204) + except Exception as e: + print("error: -", e) + return flask.make_response(flask.jsonify({'error': str(e)}), 400) + diff --git a/application/static/main.css b/application/static/main.css new file mode 100644 index 0000000..fb5047d --- /dev/null +++ b/application/static/main.css @@ -0,0 +1,23 @@ +.demo{ + max-width: 60%; + min-width: 100px; + padding: 20px; +} + +.container{ + padding:0 !important; +} + +.demo2{ + margin-left: -10px; +} + +.bg-primary1{ + background-color: rgb(255, 230, 183) !important; +} +.bg-warning1{ +background-color: rgb(255, 250, 175)!important; +} +.bg-info1{ +background-color: rgb(210, 253, 193)!important; +} \ No newline at end of file diff --git a/application/static/main.js b/application/static/main.js new file mode 100644 index 0000000..8d8cab6 --- /dev/null +++ b/application/static/main.js @@ -0,0 +1,137 @@ +var rootKontext = "/od1"; +//var rootKontext = ""; +var customeStyle = false; + +function loadOD1(){ + try{ + let ksession = $.cookie("KSESSIONID"); + var xmlHttp = new XMLHttpRequest(); + xmlHttp.open( "GET", rootKontext, false ); + xmlHttp.send(); + document.getElementById("od1").innerHTML = xmlHttp.responseText; + + $('link[title="custom"]').prop('disabled', true); + + loadData(); + } + catch(e){ + document.getElementById("od1").innerHTML = "Ein Fehler ist beim Laden des Dienstes aufgetreten, bitte versuchen Sie es später erneut."; + } +} + +function nextTab(){ + $('#navMenu1 a').removeClass("disabled"); + $('#navMenu1 a').tab('show'); +} + +function getJSON (url, callback) { + let ksession = $.cookie("KSESSIONID"); + + var xhr = new XMLHttpRequest(); + xhr.open('GET', url + "?session_id=" + ksession, true); + xhr.responseType = 'json'; + xhr.onload = function() { + var status = xhr.status; + if (status < 400) { + callback(null, xhr.response); + } else { + console.log("failed getting"); + console.log(status); + } + }; + xhr.send(); +}; + +function putJSON (url, data, callback) { + let ksession = $.cookie("KSESSIONID"); + + var xhr = new XMLHttpRequest(); + xhr.open('PUT', url + "?session_id=" + ksession, true); + xhr.responseType = 'json'; + xhr.setRequestHeader('Content-Type', 'application/json'); + xhr.onload = function() { + var status = xhr.status; + if (status < 400) { + callback(null, xhr.response); + } else { + console.log("failed posting"); + console.log(status); + } + }; + xhr.send(data); +}; + +function sendVorhaben(){ + let data = document.getElementById("form1"); + + data = {}; + data["name"] = document.getElementById("form1")["name"].value; + data["reason"] = document.getElementById("form1")["reason"].value; + data["note"] = document.getElementById("form1")["note"].value; + data["partial_application_id"] = document.getElementById("form1")["partial_application_id"].value; + + putJSON(rootKontext + "/api/v1/vorhaben/" + data["partial_application_id"], JSON.stringify(data), function(error, data){ + document.getElementById("status").innerHTML = "Daten erfolgreich erneuert"; + loadData(); + nextTab(); + }); + +} + +function queryString(string) +{ + let queryString = window.location.search; + let varArray = queryString.split("&"); + for (let i=0;i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Online Dienst 1

+ + +
+
+ +
+
+
eAst POST zu OD
+ partial_application_id:
+ +
+
+ +
+
OD GET an eAst
+ sent_date:
+
+ application_id:
+
+ official_letter_required:
+
+ name:
+
+ status:
+

+
+ +
+
Daten des OD
+ Grund:
+
+ Notiz:
+
+
+ +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a0536d3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +flask +flask_restful +sqlalchemy +requests +flask-restful-swagger-3 \ No newline at end of file diff --git a/run.py b/run.py new file mode 100644 index 0000000..2ea710a --- /dev/null +++ b/run.py @@ -0,0 +1,4 @@ +from application import app + +app.run(host="0.0.0.0",port='10024', debug=True) + diff --git a/test.sqlite b/test.sqlite new file mode 100644 index 0000000..1839cd9 Binary files /dev/null and b/test.sqlite differ