init repo soup

master
km0 2 years ago
commit cc4f18c109

18
.gitignore vendored

@ -0,0 +1,18 @@
venv/
*.pyc
__pycache__/
.ipynb_checkpoints
instance/
.pytest_cache/
.coverage
htmlcov/
dist/
build/
*.egg-info/
.env
.vscode

@ -0,0 +1,18 @@
import os
class Config(object):
DEBUG = False
TESTING = False
URL_PREFIX = ""
class ProductionConfig(Config):
DEBUG = False
URL_PREFIX = os.environ.get("URL_PREFIX")
class DevelopmentConfig(Config):
ENV = "development"
DEVELOPMENT = True
DEBUG = True

@ -0,0 +1,10 @@
from setuptools import find_packages, setup
setup(
name="soup_app",
version="1.0.0",
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=["flask", "python-dotenv", "python-frontmatter"],
)

@ -0,0 +1,8 @@
from flask import Blueprint
bp = Blueprint("home", __name__, url_prefix="/")
@bp.route("/")
def home():
return 'Hello world'

@ -0,0 +1,14 @@
class PrefixMiddleware(object):
def __init__(self, app, prefix=""):
self.app = app
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
return self.app(environ, start_response)
else:
start_response("404", [("Content-Type", "text/plain")])
return ["This url does not belong to the app.".encode()]
Loading…
Cancel
Save