started to make a docker service of it
This commit is contained in:
parent
42fdc46304
commit
3e442ae8bd
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,3 +9,5 @@ data
|
|||||||
dist
|
dist
|
||||||
venv/
|
venv/
|
||||||
/.idea/
|
/.idea/
|
||||||
|
DEADJOE
|
||||||
|
*~
|
||||||
@ -22,21 +22,21 @@ RUN apt-get update && apt-get install -y apache2 \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy over and install the requirements
|
# 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
|
RUN pip3 install -r /var/www/apache-flask/app/requirements.txt
|
||||||
|
|
||||||
# Copy over the apache configuration file and enable the site
|
# 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 a2ensite apache-flask
|
||||||
RUN a2enmod headers
|
RUN a2enmod headers
|
||||||
|
|
||||||
# Copy over the wsgi file
|
# 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 ./src/run.py /var/www/apache-flask/run.py
|
||||||
COPY ./app /var/www/apache-flask/app/
|
COPY ./src/app /var/www/apache-flask/app/
|
||||||
COPY ./wirewiz /var/www/apache-flask/wirewiz/
|
COPY ./src/wireviz /var/www/apache-flask/wireviz/
|
||||||
COPY ./static /var/www/apache-flask/static/
|
COPY ./src/static /var/www/apache-flask/static/
|
||||||
|
|
||||||
RUN a2dissite 000-default.conf
|
RUN a2dissite 000-default.conf
|
||||||
RUN a2ensite apache-flask.conf
|
RUN a2ensite apache-flask.conf
|
||||||
@ -1,7 +1,7 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
wirewiz:
|
wireviz:
|
||||||
build: .
|
build: .
|
||||||
# ports:
|
# ports:
|
||||||
# - "80:80"
|
# - "80:80"
|
||||||
@ -10,7 +10,7 @@ services:
|
|||||||
- environment.env
|
- environment.env
|
||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "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.http.services.gitlabsvgbadges.loadbalancer.server.port=80"
|
||||||
- "traefik.docker.network=traefik_proxy"
|
- "traefik.docker.network=traefik_proxy"
|
||||||
networks:
|
networks:
|
||||||
@ -7,7 +7,7 @@
|
|||||||
WSGIProcessGroup /apache-flask
|
WSGIProcessGroup /apache-flask
|
||||||
WSGIScriptAlias / /var/www/apache-flask/apache-flask.wsgi
|
WSGIScriptAlias / /var/www/apache-flask/apache-flask.wsgi
|
||||||
|
|
||||||
<Directory "/var/www/apache-flask/wirewiz/">
|
<Directory "/var/www/apache-flask/wireviz/">
|
||||||
Header set Access-Control-Allow-Origin "*"
|
Header set Access-Control-Allow-Origin "*"
|
||||||
WSGIProcessGroup /apache-flask
|
WSGIProcessGroup /apache-flask
|
||||||
WSGIApplicationGroup %{GLOBAL}
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
@ -23,11 +23,7 @@
|
|||||||
Order deny,allow
|
Order deny,allow
|
||||||
Allow from all
|
Allow from all
|
||||||
</Directory>
|
</Directory>
|
||||||
Alias /static /var/www/apache-flask/wirewiz/static
|
Alias /static /var/www/apache-flask/app/static
|
||||||
<Directory /var/www/apache-flask/wirewiz/static/>
|
|
||||||
Order allow,deny
|
|
||||||
Allow from all
|
|
||||||
</Directory>
|
|
||||||
# ErrorLog ${APACHE_LOG_DIR}/error.log
|
# ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
ErrorLog /dev/stderr
|
ErrorLog /dev/stderr
|
||||||
LogLevel warn
|
LogLevel warn
|
||||||
|
|||||||
@ -3,7 +3,7 @@ from flask_restplus import Api
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
blueprint = Blueprint('api', __name__, url_prefix='')
|
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.',)
|
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.register_blueprint(blueprint)
|
||||||
# app.config.from_object('config')
|
# app.config.from_object('config')
|
||||||
|
|||||||
@ -13,9 +13,8 @@ file_upload.add_argument('yml_file',
|
|||||||
location='files',
|
location='files',
|
||||||
required=True,
|
required=True,
|
||||||
help='YAML file')
|
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='wireviz server')
|
||||||
ns = api.namespace('', description='wirewiz server')
|
@ns.route('/wireviz/')
|
||||||
@ns.route('/wirewiz/')
|
|
||||||
class Render(Resource):
|
class Render(Resource):
|
||||||
@api.expect(file_upload)
|
@api.expect(file_upload)
|
||||||
@ns.produces(['image/png', 'image/svg+xml'])
|
@ns.produces(['image/png', 'image/svg+xml'])
|
||||||
@ -26,24 +25,28 @@ class Render(Resource):
|
|||||||
try:
|
try:
|
||||||
file_temp=tempfile.TemporaryFile()
|
file_temp=tempfile.TemporaryFile()
|
||||||
args['yml_file'].save(file_temp)
|
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)
|
file_temp.seek(0)
|
||||||
yaml_input = file_temp.read().decode()
|
yaml_input = file_temp.read().decode()
|
||||||
file_out=tempfile.NamedTemporaryFile()
|
file_out=tempfile.NamedTemporaryFile()
|
||||||
fon="%s%s" % (file_out.name, '.png')
|
fon="%s%s" % (file_out.name, '.png')
|
||||||
outputname = "%s%s" % (fon, '.png')
|
outputname = "%s%s" % (fon, '.png')
|
||||||
|
resultfilename="%s%s" % (filename, '.png')
|
||||||
mimetype='image/png'
|
mimetype='image/png'
|
||||||
if request.headers["accept"] == "image/svg+xml":
|
if request.headers["accept"] == "image/svg+xml":
|
||||||
fon="%s%s" % (file_out.name, '.svg')
|
fon="%s%s" % (file_out.name, '.svg')
|
||||||
outputname="%s%s" % (fon, '.svg')
|
outputname="%s%s" % (fon, '.svg')
|
||||||
mimetype='image/svg+xml'
|
mimetype='image/svg+xml'
|
||||||
|
resultfilename="%s%s" % (filename, '.svg')
|
||||||
wireviz.parse(yaml_input, file_out=fon)
|
wireviz.parse(yaml_input, file_out=fon)
|
||||||
return send_file(outputname,
|
return send_file(outputname,
|
||||||
as_attachment=True,
|
as_attachment=True,
|
||||||
attachment_filename=outputname,
|
attachment_filename=resultfilename,
|
||||||
mimetype=mimetype)
|
mimetype=mimetype)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return make_response(jsonify({
|
return make_response(jsonify({
|
||||||
'message': 'internal error',
|
'message': 'internal error',
|
||||||
'exception': str(e)
|
'exception': str(e)
|
||||||
}), 500)
|
}), 500)
|
||||||
|
|||||||
70
src/app/static/index.html
Normal file
70
src/app/static/index.html
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<title>WireViz Server</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
||||||
|
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-teal.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<header class="w3-container w3-theme w3-padding" id="myHeader">
|
||||||
|
<!--i onclick="w3_open()" class="fa fa-bars w3-xlarge w3-button w3-theme"></i-->
|
||||||
|
<div class="w3-center">
|
||||||
|
<h4>by Jürgen "EL BOSSO" Key</h4>
|
||||||
|
<h1 class="w3-xxxlarge w3-animate-bottom">WireViz Server</h1>
|
||||||
|
<div class="w3-padding-16">
|
||||||
|
<a class="w3-btn w3-large w3-theme-dark w3-hover-teal" href="https://github.com/elbosso/WireViz">Visit project website!</a>
|
||||||
|
</div>
|
||||||
|
<div class="w3-padding-16">
|
||||||
|
<a class="w3-btn w3-large w3-theme-dark w3-hover-teal" href="https://elbosso.github.io">Visit authors website!</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="w3-row-padding w3-margin-top">
|
||||||
|
<div class="w3-twothird">
|
||||||
|
<div class="w3-card w3-container" style="min-height:500px">
|
||||||
|
<h3>Usage</h3>
|
||||||
|
<p>You get a nice PNG image like so:</p>
|
||||||
|
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">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</div>
|
||||||
|
<p>You get a nice SVG image like so:</p>
|
||||||
|
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">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</div>
|
||||||
|
<p>If there is no preference specified - the result will be a nice PNG image:</p>
|
||||||
|
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">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</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w3-third" style="min-height:500px">
|
||||||
|
<div class="w3-card-padding w3-container" >
|
||||||
|
<h3>Ressources</h3>
|
||||||
|
<p><a href="/demo01.yml">Demo file for testing purposes</a></p>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
<div class="w3-card-padding w3-container">
|
||||||
|
<h3>Request PNG...</h3>
|
||||||
|
<form action="/wireviz/" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="w3-row-padding w3-margin-top"><input name="yml_file" type="file" accept="application/x-yaml"></div>
|
||||||
|
<div class="w3-row-padding w3-margin-top"><input type="submit" title="Request PNG rendering" value="Request PNG rendering"/></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="w3-container w3-theme-dark">
|
||||||
|
<!--h3>Footer</h3-->
|
||||||
|
<p>Powered by <a href="https://www.w3schools.com/w3css/default.asp" target="_blank">w3.css</a></p>
|
||||||
|
<!--div style="position:relative;bottom:55px;" class="w3-tooltip w3-right">
|
||||||
|
Go To Top
|
||||||
|
<a class="w3-text-white" href="#myHeader">
|
||||||
|
<i class="fa fa-chevron-circle-up"></i></a>
|
||||||
|
</div>
|
||||||
|
<p>Remember to check out our <a href="w3css_references.asp" class="w3-btn w3-theme" target="_blank">W3.CSS Reference</a></p-->
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,90 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<title>RFC 3161 Timestamp Server</title>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
|
||||||
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-teal.css">
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css">
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<!-- Header -->
|
|
||||||
<header class="w3-container w3-theme w3-padding" id="myHeader">
|
|
||||||
<!--i onclick="w3_open()" class="fa fa-bars w3-xlarge w3-button w3-theme"></i-->
|
|
||||||
<div class="w3-center">
|
|
||||||
<h4>by Jürgen "EL BOSSO" Key</h4>
|
|
||||||
<h1 class="w3-xxxlarge w3-animate-bottom">RFC 3161 Timestamp Server</h1>
|
|
||||||
<div class="w3-padding-16">
|
|
||||||
<a class="w3-btn w3-large w3-theme-dark w3-hover-teal" href="https://github.com/elbosso/rfc3161timestampingserver">Visit project website!</a>
|
|
||||||
</div>
|
|
||||||
<div class="w3-padding-16">
|
|
||||||
<a class="w3-btn w3-large w3-theme-dark w3-hover-teal" href="https://elbosso.github.io">Visit authors website!</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="w3-row-padding w3-margin-top">
|
|
||||||
<div class="w3-twothird">
|
|
||||||
<div class="w3-card w3-container" style="min-height:500px">
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<p>The OpenSSL configuration provided as ressource can be used with
|
|
||||||
<a href="https://www.openssl.org/" rel="nofollow">OpenSSL</a> to create a certificate
|
|
||||||
request like so:</p>
|
|
||||||
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">openssl ts -query -config tsa.conf -cert -sha512 -data <path>/<some_file> -no_nonce -out <request_path>/<request>.tsq</div>
|
|
||||||
<p>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):</p>
|
|
||||||
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">curl -F "tsq=@<request>.tsq" http://<host>:<port>/ ><reply>.tsr</div>
|
|
||||||
<p>The file <em>reply.tsr</em> 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:</p>
|
|
||||||
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">curl -H "Content-Type: application/timestamp-query" --data-binary '@<request>.tsq' http://<host>:<port>/ ><reply>.tsr</div>
|
|
||||||
<p>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:</p>
|
|
||||||
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">openssl ts -config tsa.conf -reply -in <reply>.tsr -text</div>
|
|
||||||
<p>To verify the timestamp, OpenSSL can help too:</p>
|
|
||||||
<div class="w3-panel w3-leftbar w3-sand w3-tiny w3-mono">openssl ts -verify -config tsa.conf -queryfile <request>.tsq -in <reply>.tsr -CAfile chain.pem</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="w3-third" style="min-height:500px">
|
|
||||||
<div class="w3-card-padding w3-container" >
|
|
||||||
<h3>Ressources</h3>
|
|
||||||
<p><a href="/tsa.crt">Timestamping Authority (TSA) Certificate</a></p>
|
|
||||||
<p><a href="/chain.pem">Certificate Chain for TSA</a></p>
|
|
||||||
<p><a href="/tsa.conf">OpenSSL configuration for client operations</a></p>
|
|
||||||
<p></p>
|
|
||||||
</div>
|
|
||||||
<div class="w3-card-padding w3-container">
|
|
||||||
<h3>Search timestamp...</h3>
|
|
||||||
<form action="/query" method="post">
|
|
||||||
<div class="w3-row-padding w3-tiny w3-margin-top"><textarea rows="3" style="width: 100%; height: 100%" name="msgDigestHex"></textarea></div>
|
|
||||||
<div class="w3-row-padding w3-margin-top"><input type="submit" title="Find..." value="Find..."/></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="w3-card-padding w3-container">
|
|
||||||
<h3>Request timestamp...</h3>
|
|
||||||
<form action="/" method="post" enctype="multipart/form-data">
|
|
||||||
<div class="w3-row-padding w3-margin-top"><input name="tsq" type="file" accept="application/timestamp-query"></div>
|
|
||||||
<div class="w3-row-padding w3-margin-top"><input type="submit" title="Request Timestamp" value="Request Timestamp"/></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Footer -->
|
|
||||||
<footer class="w3-container w3-theme-dark">
|
|
||||||
<!--h3>Footer</h3-->
|
|
||||||
<p>Powered by <a href="https://www.w3schools.com/w3css/default.asp" target="_blank">w3.css</a></p>
|
|
||||||
<!--div style="position:relative;bottom:55px;" class="w3-tooltip w3-right">
|
|
||||||
Go To Top
|
|
||||||
<a class="w3-text-white" href="#myHeader">
|
|
||||||
<i class="fa fa-chevron-circle-up"></i></a>
|
|
||||||
</div>
|
|
||||||
<p>Remember to check out our <a href="w3css_references.asp" class="w3-btn w3-theme" target="_blank">W3.CSS Reference</a></p-->
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user