Skip to content
Snippets Groups Projects
Verified Commit c3ab04a0 authored by David Beniamine's avatar David Beniamine
Browse files

Initial commit

parents
Branches 24-badpathinpostinstall
No related tags found
No related merge requests found
FROM debian:buster
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get update
RUN apt-get install -y \
apache2 \
libapache2-mod-wsgi-py3 \
python-dev \
python3-pip
RUN pip3 install flask
COPY flask.conf /etc/apache2/sites-available
RUN a2dissite 000-default
RUN a2ensite flask
# Force code reloading
RUN sed -i 's/^\(\s*MaxConnectionsPerChild\s*\) 0/\1 1/g' /etc/apache2/mods-enabled/mpm_event.conf
ENTRYPOINT ["apache2ctl", "-DFOREGROUND"]
# Unl To Rdf
This is a one page [flask](https://flask.palletsprojects.com) app to convert unl to rdf, the web app is full python, everything is in the file `src/app/app.py`.
The display rendering uses the templates in the directory `src/app/templates` see [flakes templating](https://flask.palletsprojects.com/en/1.1.x/quickstart/#rendering-templates).
version: '2'
services:
front:
build: ./
volumes:
- "./src:/var/www/app"
environment:
APP_DEBUG: ${APP_DEBUG}
restart: ${RESTART}
ports:
- "${DEV_PORT}:80"
restart: ${RESTART}
<VirtualHost *:80>
# Give an alias to to start your website url with
WSGIScriptAlias / /var/www/app/app.wsgi
<Directory /var/www/app/app/>
# set permissions as per apache2.conf file
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
#! /usr/bin/env python3
import logging
import sys
import os
logging.basicConfig(stream=sys.stderr)
path = os.path.dirname(__file__)+'/app'
if path not in sys.path:
sys.path.append(path)
from app import app as application
from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__)
@app.route('/')
def main():
return render_template('main.html')
@app.route('/', methods=['POST'])
def handle():
unl = request.form['unl']
rdf = unlToRdf(unl)
return render_template('output.html', unl=unl, rdf=rdf)
def unlToRdf(unl):
# TODO handle text here, do not call bash command or sanitize input first
return "Please implement me so I can convert '{}' to RDF".format(unl)
<!DOCTYPE html>
<html lang="en">
<head>
<title>UNL 2 RDF demo</title>
</head>
<body>
<h1>Enter some UNL here I will convert it to RDF for you</h1>
<form action="/" method="POST">
<textarea name="unl" cols="80" rows="10" style="width: 300px; height: 150px;"></textarea>
<input type="submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>UNL 2 RDF demo</title>
</head>
<body>
<h1>UNL 2 RDF demo</h1>
<h2> UNL </h2>
<pre>
<code>
{{ unl }}
</code>
</pre>
<h2> RDF </h2>
<pre>
<code>
{{ rdf }}
</code>
</pre>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment