mirror of
https://github.com/NovaOSS/nova-web.git
synced 2024-11-25 19:33:57 +01:00
lil' cleanup
This commit is contained in:
parent
e2d29c844a
commit
c9ca4d8873
38
web/app.py
38
web/app.py
|
@ -19,6 +19,9 @@ def create_app() -> flask.Flask:
|
|||
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1
|
||||
)
|
||||
|
||||
import tos
|
||||
tos.register(app)
|
||||
|
||||
@app.context_processor
|
||||
def inject_variables():
|
||||
return {
|
||||
|
@ -59,41 +62,6 @@ def create_app() -> flask.Flask:
|
|||
|
||||
return flask.render_template(f'legal/{subpath}.html', verify=emoji)
|
||||
|
||||
@app.route('/api/tos-verification', methods=['POST'])
|
||||
def tos_verification_api():
|
||||
if not flask.request.headers.get('Authorization') == os.getenv('TOS_VERIFICATION_KEY'):
|
||||
return 'Unauthorized', 401
|
||||
|
||||
code = secrets.token_urlsafe(6)
|
||||
emoji = random.choice(open('config/emojis.txt', encoding='utf8').read())
|
||||
|
||||
if not os.path.exists('data/tos.json'):
|
||||
open('data/tos.json', 'w', encoding='utf8').write('{}')
|
||||
|
||||
try:
|
||||
data = json.load(open('data/tos.json', encoding='utf8'))
|
||||
except json.decoder.JSONDecodeError:
|
||||
data = {}
|
||||
|
||||
data[code] = emoji
|
||||
json.dump(data, open('data/tos.json', 'w', encoding='utf8'))
|
||||
|
||||
return {
|
||||
'code': code,
|
||||
'emoji': emoji
|
||||
}
|
||||
|
||||
@app.route('/api/tos-verification/<code>', methods=['DELETE'])
|
||||
def tos_verification_api_delete(code):
|
||||
if not flask.request.headers.get('Authorization') == os.getenv('TOS_VERIFICATION_KEY'):
|
||||
return 'Unauthorized', 401
|
||||
|
||||
data = json.load(open('data/tos.json', encoding='utf8'))
|
||||
del data[code]
|
||||
json.dump(data, open('data/tos.json', 'w', encoding='utf8'))
|
||||
|
||||
return 'Removed.', 204
|
||||
|
||||
return app
|
||||
|
||||
production = create_app()
|
||||
|
|
|
@ -1,18 +1 @@
|
|||
{% include 'parts/begin.html' %}
|
||||
|
||||
<main>
|
||||
<h1>Impressum (Imprint)</h1>
|
||||
<p>
|
||||
<s>My name is Walter Hartwell White. I live at 308 Negra Arroyo Lane, Albuquerque, New Mexico, 87104.</s>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Hierbei handelt es sich gemäß § 5 TMG um eine private Internetseite für Freunde und Bekannte ohne kommerzielle Interessen.
|
||||
Entsprechend entfällt die <a target="_blank" href="https://www.bmuv.de/themen/verbraucherschutz-im-bmuv/digitaler-verbraucherschutz/impressumspflicht#c66866">
|
||||
Notwendigkeit
|
||||
</a>
|
||||
eines Impressums.
|
||||
</p>
|
||||
</main>
|
||||
|
||||
{% include 'parts/end.html' %}
|
||||
<meta http-equiv="REFRESH" content="0; url=https://youtu.be/dQw4w9WgXcQ">
|
45
web/tos.py
Normal file
45
web/tos.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
import os
|
||||
import json
|
||||
import flask
|
||||
import random
|
||||
import secrets
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
def register(app):
|
||||
@app.route('/api/tos-verification', methods=['POST'])
|
||||
def tos_verification_api():
|
||||
if not flask.request.headers.get('Authorization') == os.getenv('TOS_VERIFICATION_KEY'):
|
||||
return 'Unauthorized', 401
|
||||
|
||||
code = secrets.token_urlsafe(6)
|
||||
emoji = random.choice(open('config/emojis.txt', encoding='utf8').read())
|
||||
|
||||
if not os.path.exists('data/tos.json'):
|
||||
open('data/tos.json', 'w', encoding='utf8').write('{}')
|
||||
|
||||
try:
|
||||
data = json.load(open('data/tos.json', encoding='utf8'))
|
||||
except json.decoder.JSONDecodeError:
|
||||
data = {}
|
||||
|
||||
data[code] = emoji
|
||||
json.dump(data, open('data/tos.json', 'w', encoding='utf8'))
|
||||
|
||||
return {
|
||||
'code': code,
|
||||
'emoji': emoji
|
||||
}
|
||||
|
||||
@app.route('/api/tos-verification/<code>', methods=['DELETE'])
|
||||
def tos_verification_api_delete(code):
|
||||
if not flask.request.headers.get('Authorization') == os.getenv('TOS_VERIFICATION_KEY'):
|
||||
return 'Unauthorized', 401
|
||||
|
||||
data = json.load(open('data/tos.json', encoding='utf8'))
|
||||
del data[code]
|
||||
json.dump(data, open('data/tos.json', 'w', encoding='utf8'))
|
||||
|
||||
return 'Removed.', 204
|
Loading…
Reference in a new issue