diff --git a/.gitignore b/.gitignore
index 9e8695a..95dd5fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ data
dist
venv/
/.idea/
+DEADJOE
+*~
\ No newline at end of file
diff --git a/src/Dockerfile b/Dockerfile
similarity index 73%
rename from src/Dockerfile
rename to Dockerfile
index 083f1be..ff9935a 100644
--- a/src/Dockerfile
+++ b/Dockerfile
@@ -22,21 +22,21 @@ RUN apt-get update && apt-get install -y apache2 \
&& rm -rf /var/lib/apt/lists/*
# Copy over and install the requirements
-COPY ../requirements.txt /var/www/apache-flask/app/requirements.txt
+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
+COPY ./src/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 ./src/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/
+COPY ./src/run.py /var/www/apache-flask/run.py
+COPY ./src/app /var/www/apache-flask/app/
+COPY ./src/wireviz /var/www/apache-flask/wireviz/
+COPY ./src/static /var/www/apache-flask/static/
RUN a2dissite 000-default.conf
RUN a2ensite apache-flask.conf
diff --git a/src/docker-compose.yml b/docker-compose.yml
similarity index 84%
rename from src/docker-compose.yml
rename to docker-compose.yml
index e397b63..467975f 100644
--- a/src/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,7 +1,7 @@
version: '2'
services:
- wirewiz:
+ wireviz:
build: .
# ports:
# - "80:80"
@@ -10,7 +10,7 @@ services:
- environment.env
labels:
- "traefik.enable=true"
- - "traefik.http.routers.gitlabsvgbadges.rule=Host(`wirewiz.docker.lab`)"
+ - "traefik.http.routers.gitlabsvgbadges.rule=Host(`wireviz.docker.lab`)"
- "traefik.http.services.gitlabsvgbadges.loadbalancer.server.port=80"
- "traefik.docker.network=traefik_proxy"
networks:
diff --git a/src/apache-flask.conf b/src/apache-flask.conf
index 3a89b3b..e28cfe4 100644
--- a/src/apache-flask.conf
+++ b/src/apache-flask.conf
@@ -7,7 +7,7 @@
WSGIProcessGroup /apache-flask
WSGIScriptAlias / /var/www/apache-flask/apache-flask.wsgi
-
+
Header set Access-Control-Allow-Origin "*"
WSGIProcessGroup /apache-flask
WSGIApplicationGroup %{GLOBAL}
@@ -23,11 +23,7 @@
Order deny,allow
Allow from all
- Alias /static /var/www/apache-flask/wirewiz/static
-
- Order allow,deny
- Allow from all
-
+ Alias /static /var/www/apache-flask/app/static
# ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog /dev/stderr
LogLevel warn
diff --git a/src/app/__init__.py b/src/app/__init__.py
index d1da5a2..5b9334d 100644
--- a/src/app/__init__.py
+++ b/src/app/__init__.py
@@ -3,7 +3,7 @@ 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',
+api = Api(blueprint, doc='/doc/', version='1.0', title='WireViz 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')
diff --git a/src/app/server.py b/src/app/server.py
index 1ba575c..5396253 100644
--- a/src/app/server.py
+++ b/src/app/server.py
@@ -13,9 +13,8 @@ file_upload.add_argument('yml_file',
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/')
+ns = api.namespace('', description='wireviz server')
+@ns.route('/wireviz/')
class Render(Resource):
@api.expect(file_upload)
@ns.produces(['image/png', 'image/svg+xml'])
@@ -26,24 +25,28 @@ class Render(Resource):
try:
file_temp=tempfile.TemporaryFile()
args['yml_file'].save(file_temp)
+ filename=os.path.splitext(os.path.basename(os.path.normpath(args['yml_file'].filename)))[0]
+ print(filename)
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')
+ resultfilename="%s%s" % (filename, '.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'
+ resultfilename="%s%s" % (filename, '.svg')
wireviz.parse(yaml_input, file_out=fon)
return send_file(outputname,
as_attachment=True,
- attachment_filename=outputname,
+ attachment_filename=resultfilename,
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
+ }), 500)
diff --git a/src/app/static/index.html b/src/app/static/index.html
new file mode 100644
index 0000000..3efa2e1
--- /dev/null
+++ b/src/app/static/index.html
@@ -0,0 +1,70 @@
+
+
+
WireViz Server
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Usage
+
You get a nice PNG image like so:
+
curl -X POST "http://<host>:<port>/wireviz/" -H "Content-Type: multipart/form-data" -H "accept: image/png" -F "yml_file=@<input_file>.yml;type=application/x-yaml" -o <output_file>.png
+
You get a nice SVG image like so:
+
curl -X POST "http://<host>:<port>/wireviz/" -H "Content-Type: multipart/form-data" -H "accept: image/svg+xml" -F "yml_file=@<input_file>.yml;type=application/x-yaml" -o <output_file>.svg
+
If there is no preference specified - the result will be a nice PNG image:
+
curl -X POST "http://<host>:<port>/wireviz/" -H "Content-Type: multipart/form-data" -F "yml_file=@<input_file>.yml;type=application/x-yaml" -o <output_file>.png
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/static/index.html b/src/static/index.html
deleted file mode 100644
index 0a787c3..0000000
--- a/src/static/index.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-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