diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..018ab57 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source .venv/bin/activate +export FLASK_ENV=development +export FLASK_APP=index.py diff --git a/config/001-od2m.conf b/config/001-od2m.conf new file mode 100644 index 0000000..5a1aadc --- /dev/null +++ b/config/001-od2m.conf @@ -0,0 +1,45 @@ + + + ServerName ouvriersdeuxmondes.huma-num.fr + ServerAdmin jean-damien.genero@ehess.fr + + # Document root doesn't really matter as it will be overriden + DocumentRoot /var/www/html + + # WSGI configuration + # - name the process od2m + # - run it as dedicated www-od2m user + WSGIDaemonProcess od2m user=www-od2m group=www-od2m threads=5 python-home=/var/www/od2m/.venv/ locale=en_US.UTF-8 socket-timeout=600 + WSGIScriptAlias / /var/www/od2m/wsgi.py + + WSGIProcessGroup od2m + WSGIApplicationGroup %{GLOBAL} + Order deny,allow + Allow from all + + + # Log files configuration + ErrorLog ${APACHE_LOG_DIR}/od2m-error.log + CustomLog ${APACHE_LOG_DIR}/od2m-access.log combined + + # SSL configuration + SSLEngine on + SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + Include /etc/letsencrypt/options-ssl-apache.conf + SSLCertificateFile /etc/letsencrypt/live/ouvriersdeuxmondes.huma-num.fr/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/ouvriersdeuxmondes.huma-num.fr/privkey.pem + + + + # Make the HTTP virtual host redirect to HTTPS + ServerName ouvriersdeuxmondes.huma-num.fr + Redirect / https://ouvriersdeuxmondes.huma-num.fr + + \ No newline at end of file diff --git a/config/wsgi_od2m.load b/config/wsgi_od2m.load new file mode 100644 index 0000000..696aa03 --- /dev/null +++ b/config/wsgi_od2m.load @@ -0,0 +1,2 @@ +LoadModule wsgi_module "/var/www/od2m/.venv/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so" +WSGIPythonHome "/var/www/od2m/.venv" diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..83ed4bf --- /dev/null +++ b/debug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export DEBUGGER=True +"$@" diff --git a/index.py b/index.py new file mode 100644 index 0000000..72b682d --- /dev/null +++ b/index.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + + +""" +author = Jean-Damien Généro +date = 2020-12-15 +""" + + +from app import app + +if __name__ == "__main__": + app.run(debug=True) diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..ad7037e --- /dev/null +++ b/mypy.ini @@ -0,0 +1,4 @@ +[mypy] +ignore_missing_imports=True +follow_imports=silent +show_column_numbers=True diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..dca955d --- /dev/null +++ b/tox.ini @@ -0,0 +1,17 @@ +[flake8] +# E501: line too long -> managed by black, allow some lines (docstring, etc.) to be longer +# W503: Line break occurred before a binary operator -> preferred way for black +# E203: Whitespace before ':' -> managed by black, allow some cases (subscripting, etc.) +ignore = E501, W503, E203 +max-line-length = 110 + +[isort] +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True +line_length = 110 + +[pytest] +norecursedirs = .venv .eggs diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..32b15e4 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,18 @@ +import os +import sys +import typing as t + +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) +activate_this = os.path.abspath(os.path.dirname(__file__)) + "/.venv/bin/activate_this.py" + +if os.path.exists(activate_this): + with open(activate_this) as file_: + exec(file_.read(), dict(__file__=activate_this)) + + # On importe l'app uniquement APRES avoir activé le virtualenv + from app import app + + app.config["FLASK_ENV"] = "production" + + def application(req_environ: dict, start_response: t.Callable) -> t.Any: + return app(req_environ, start_response)