initial commit

This commit is contained in:
mwiegand 2023-03-03 17:46:35 +01:00
commit 1bb04e3080
No known key found for this signature in database
8 changed files with 75 additions and 0 deletions

8
.envrc Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
python3 -m venv .venv
source ./.venv/bin/activate
PATH_add .venv/bin
PATH_add bin
python3 -m pip install --upgrade pip

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.venv
.vscode
__pycache__

1
README.md Normal file
View file

@ -0,0 +1 @@
export FLASK_APP=ckn_blog flask run

42
ckn_blog/__init__.py Normal file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env python3
from flask import Flask, abort
import markdown as Markdown
from os.path import join, isfile
from functools import cache
from os import getenv
data_path = getenv('DATA_PATH', 'data')
app = Flask(__name__)
@cache
def pathfinder(path):
if path == '/':
path = ''
for local_path in [
join(data_path, f'{path}.md'),
join(data_path, path, 'index.md'),
]:
if isfile(local_path):
return local_path
abort(404)
@cache
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
local_path = pathfinder(path)
if isfile(local_path):
with open(local_path, 'r') as file:
return Markdown.markdown(file.read())
@app.route('/favicon.ico')
def favicon():
return ""

12
data/index.md Normal file
View file

@ -0,0 +1,12 @@
HALLO WELT
==========
was geht ab?
- alles
- nicht
- manches
```ruby
puts "hello welt"
```

1
data/test.md Normal file
View file

@ -0,0 +1 @@
i bims ein TEST

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
Flask
markdown

6
setup.py Normal file
View file

@ -0,0 +1,6 @@
from setuptools import find_packages, setup
setup(
name="ckn_blog",
packages=find_packages(),
)