db
km0 2 years ago
parent ef1ceab64a
commit 811a9cf816

@ -5,6 +5,6 @@ importlib-metadata==4.11.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
PyYAML==6.0
Werkzeug==2.1.2
zipp==3.8.0
python-dotenv==0.21.0

@ -1,14 +1,11 @@
from flask import Flask, render_template, request, redirect, url_for, jsonify
from werkzeug.utils import secure_filename
import json
from pathlib import Path
import sqlite3
from dotenv import load_dotenv
from pathlib import Path
import os
Path(f'static/panels/').mkdir(exist_ok=True)
Path(f'static/cables/').mkdir(exist_ok=True)
Path(f'static/snippets/').mkdir(exist_ok=True)
class PrefixMiddleware(object):
def __init__(self, app, prefix=""):
@ -16,7 +13,7 @@ class PrefixMiddleware(object):
self.prefix = prefix
def __call__(self, environ, start_response):
if environ["PATH_INFO"].startswith(self.prefix):
environ["PATH_INFO"] = environ["PATH_INFO"][len(self.prefix) :]
environ["SCRIPT_NAME"] = self.prefix
@ -26,11 +23,16 @@ class PrefixMiddleware(object):
return ["This url does not belong to the app.".encode()]
app = Flask(__name__)
load_dotenv()
Path(f'static/panels/').mkdir(exist_ok=True)
Path(f'static/cables/').mkdir(exist_ok=True)
Path(f'static/snippets/').mkdir(exist_ok=True)
app = Flask(__name__)
# register the middleware to prefix all the requests with our base_url
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix='/soupboat/workbook')
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=os.environ.get('BASE_URL', ''))
def get_db_connection():

Loading…
Cancel
Save