diff --git a/.gitignore b/.gitignore
index cc614ad..9e8695a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ build
data
dist
venv/
+/.idea/
diff --git a/requirements.txt b/requirements.txt
index 9c558e3..4c46c7c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,7 @@
-.
+Flask
+requests
+flask-restplus
+Werkzeug==0.16.1
+dataclasses
+pyyaml
+graphviz
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 950e314..5ed3173 100644
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@ setup(
install_requires=[
'pyyaml',
'graphviz',
+
],
license='GPLv3',
keywords='cable connector hardware harness wiring wiring-diagram wiring-harness',
diff --git a/src/Dockerfile b/src/Dockerfile
new file mode 100644
index 0000000..083f1be
--- /dev/null
+++ b/src/Dockerfile
@@ -0,0 +1,53 @@
+############################################################
+# Dockerfile to build Flask App
+# Based on
+############################################################
+
+# Set the base image
+FROM debian:latest
+
+# File Author / Maintainer
+MAINTAINER Jürgen Key
+
+RUN apt-get update && apt-get install -y apache2 \
+ libapache2-mod-wsgi-py3 \
+ build-essential \
+ python3 \
+ python3-dev\
+ python3-pip \
+ joe \
+ graphviz \
+ && apt-get clean \
+ && apt-get autoremove \
+ && rm -rf /var/lib/apt/lists/*
+
+# Copy over and install the requirements
+COPY ../requirements.txt /var/www/apache-flask/app/requirements.txt
+RUN pip3 install -r /var/www/apache-flask/app/requirements.txt
+
+# Copy over the apache configuration file and enable the site
+COPY ./apache-flask.conf /etc/apache2/sites-available/apache-flask.conf
+RUN a2ensite apache-flask
+RUN a2enmod headers
+
+# Copy over the wsgi file
+COPY ./apache-flask.wsgi /var/www/apache-flask/apache-flask.wsgi
+
+COPY ./run.py /var/www/apache-flask/run.py
+COPY ./app /var/www/apache-flask/app/
+COPY ./wirewiz /var/www/apache-flask/wirewiz/
+COPY ./static /var/www/apache-flask/static/
+
+RUN a2dissite 000-default.conf
+RUN a2ensite apache-flask.conf
+
+EXPOSE 80
+
+WORKDIR /var/www/apache-flask
+
+# CMD ["/bin/bash"]
+CMD /usr/sbin/apache2ctl -D FOREGROUND
+# The commands below get apache running but there are issues accessing it online
+# The port is only available if you go to another port first
+# ENTRYPOINT ["/sbin/init"]
+# CMD ["/usr/sbin/apache2ctl"]
diff --git a/src/apache-flask.conf b/src/apache-flask.conf
new file mode 100644
index 0000000..3a89b3b
--- /dev/null
+++ b/src/apache-flask.conf
@@ -0,0 +1,38 @@
+# -*- apache -*-
+
+
+
+ # Python application integration
+ WSGIDaemonProcess /apache-flask processes=4 threads=20 python-path=/var/www/apache-flask/:/usr/bin/python3
+ WSGIProcessGroup /apache-flask
+ WSGIScriptAlias / /var/www/apache-flask/apache-flask.wsgi
+
+
+ Header set Access-Control-Allow-Origin "*"
+ WSGIProcessGroup /apache-flask
+ WSGIApplicationGroup %{GLOBAL}
+ Options +ExecCGI
+ Order deny,allow
+ Allow from all
+
+
+ Header set Access-Control-Allow-Origin "*"
+ WSGIProcessGroup /apache-flask
+ WSGIApplicationGroup %{GLOBAL}
+ Options +ExecCGI
+ Order deny,allow
+ Allow from all
+
+ Alias /static /var/www/apache-flask/wirewiz/static
+
+ Order allow,deny
+ Allow from all
+
+# ErrorLog ${APACHE_LOG_DIR}/error.log
+ ErrorLog /dev/stderr
+ LogLevel warn
+# CustomLog ${APACHE_LOG_DIR}/access.log combined
+ TransferLog /dev/stdout
+ CustomLog /dev/stdout combined
+
+
\ No newline at end of file
diff --git a/src/app/__init__.py b/src/app/__init__.py
new file mode 100644
index 0000000..d1da5a2
--- /dev/null
+++ b/src/app/__init__.py
@@ -0,0 +1,10 @@
+from flask import Flask, Blueprint
+from flask_restplus import Api
+
+app = Flask(__name__)
+blueprint = Blueprint('api', __name__, url_prefix='')
+api = Api(blueprint, doc='/doc/', version='1.0', title='WireWiz server',
+ description='WireViz is a tool for easily documenting cables, wiring harnesses and connector pinouts. It takes plain text, YAML-formatted files as input and produces beautiful graphical output (SVG, PNG, ...) thanks to GraphViz. It handles automatic BOM (Bill of Materials) creation and has a lot of extra features.',)
+app.register_blueprint(blueprint)
+# app.config.from_object('config')
+from app import server
\ No newline at end of file
diff --git a/src/app/server.py b/src/app/server.py
new file mode 100644
index 0000000..1ba575c
--- /dev/null
+++ b/src/app/server.py
@@ -0,0 +1,49 @@
+from flask import send_file
+from flask import request, jsonify, send_file, make_response
+from app import app, api
+import os
+from flask_restplus import Resource, reqparse
+import werkzeug
+import tempfile
+from wireviz import wireviz
+
+file_upload = reqparse.RequestParser()
+file_upload.add_argument('yml_file',
+ type=werkzeug.datastructures.FileStorage,
+ location='files',
+ required=True,
+ help='YAML file')
+#curl -X POST "http://localhost:5000/wirewiz/" -H "Content-Type: multipart/form-data" -F "yml_file=@/home/elbosso/Desktop/demo01.yml;type=application/x-yaml"
+ns = api.namespace('', description='wirewiz server')
+@ns.route('/wirewiz/')
+class Render(Resource):
+ @api.expect(file_upload)
+ @ns.produces(['image/png', 'image/svg+xml'])
+ def post(self):
+ """
+ """
+ args = file_upload.parse_args()
+ try:
+ file_temp=tempfile.TemporaryFile()
+ args['yml_file'].save(file_temp)
+ file_temp.seek(0)
+ yaml_input = file_temp.read().decode()
+ file_out=tempfile.NamedTemporaryFile()
+ fon="%s%s" % (file_out.name, '.png')
+ outputname = "%s%s" % (fon, '.png')
+ mimetype='image/png'
+ if request.headers["accept"] == "image/svg+xml":
+ fon="%s%s" % (file_out.name, '.svg')
+ outputname="%s%s" % (fon, '.svg')
+ mimetype='image/svg+xml'
+ wireviz.parse(yaml_input, file_out=fon)
+ return send_file(outputname,
+ as_attachment=True,
+ attachment_filename=outputname,
+ mimetype=mimetype)
+ except Exception as e:
+ print(e)
+ return make_response(jsonify({
+ 'message': 'internal error',
+ 'exception': str(e)
+ }), 500)
\ No newline at end of file
diff --git a/src/static/index.html b/src/static/index.html
new file mode 100644
index 0000000..0a787c3
--- /dev/null
+++ b/src/static/index.html
@@ -0,0 +1,90 @@
+
+
+
RFC 3161 Timestamp Server
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Usage
+
The OpenSSL configuration provided as ressource can be used with
+ OpenSSL to create a certificate
+ request like so:
+
openssl ts -query -config tsa.conf -cert -sha512 -data <path>/<some_file> -no_nonce -out <request_path>/<request>.tsq
+
This request can be sent using a HTTP POST request as multipart form data
+ (for example from a file upload form inside a web page):
+
curl -F "tsq=@<request>.tsq" http://<host>:<port>/ ><reply>.tsr
+
The file reply.tsr contains the timestamp. Alternatively,
+ this also works with a POST request containing the timestamp query in
+ the body of said request having the correct mime-type:
+
curl -H "Content-Type: application/timestamp-query" --data-binary '@<request>.tsq' http://<host>:<port>/ ><reply>.tsr
+
The content of the timestamp (useful for ascertaining the time and date
+ for example) can be displayed for example with the help of
+ OpenSSL command line tools like so:
+
openssl ts -config tsa.conf -reply -in <reply>.tsr -text
+
To verify the timestamp, OpenSSL can help too:
+
openssl ts -verify -config tsa.conf -queryfile <request>.tsq -in <reply>.tsr -CAfile chain.pem
+
+
+
+
+
+
+
Search timestamp...
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file