diff --git a/compose.yml b/compose.yml
index 3b1f650..24e186c 100644
--- a/compose.yml
+++ b/compose.yml
@@ -6,5 +6,6 @@ services:
- "8081:8081"
volumes:
- ./:/code
- entrypoint: ["python","-m","snek.app"]
+ entrypoint: ["gunicorn", "-w", "1", "-k", "aiohttp.worker.GunicornWebWorker", "snek.gunicorn:app","--bind","0.0.0.0:8081"]
+ #["python","-m","snek.app"]
\ No newline at end of file
diff --git a/src/snek/app.py b/src/snek/app.py
index db9ebf9..f25ffba 100644
--- a/src/snek/app.py
+++ b/src/snek/app.py
@@ -7,6 +7,7 @@ from jinja_markdown2 import MarkdownExtension
from snek.system import http
from snek.system.middleware import cors_middleware
from snek.view.about import AboutHTMLView, AboutMDView
+from snek.view.docs import DocsHTMLView, DocsMDView
from snek.view.index import IndexView
from snek.view.login import LoginView
from snek.view.login_form import LoginFormView
@@ -39,6 +40,9 @@ class Application(BaseApplication):
)
self.router.add_view("/about.html", AboutHTMLView)
self.router.add_view("/about.md", AboutMDView)
+ self.router.add_view("/docs.html", DocsHTMLView)
+ self.router.add_view("/docs.md", DocsMDView)
+
self.router.add_view("/web.html", WebView)
self.router.add_view("/login.html", LoginView)
self.router.add_view("/login.json", LoginFormView)
@@ -66,7 +70,7 @@ class Application(BaseApplication):
)
- @time_cache_async(60)
+ #@time_cache_async(60)
async def render_template(self, template, request, context=None):
return await super().render_template(template, request, context)
diff --git a/src/snek/system/markdown.py b/src/snek/system/markdown.py
index 93bc08c..489a3e5 100644
--- a/src/snek/system/markdown.py
+++ b/src/snek/system/markdown.py
@@ -9,6 +9,7 @@ from pygments.lexers import get_lexer_by_name
from pygments.formatters import html
from pygments.styles import get_style_by_name
import functools
+from app.cache import time_cache_async
class MarkdownRenderer(HTMLRenderer):
def __init__(self, app, template):
@@ -28,7 +29,6 @@ class MarkdownRenderer(HTMLRenderer):
#return '\n
%s
\n' % escape(code)
lexer = get_lexer_by_name(lang, stripall=True)
formatter = html.HtmlFormatter(lineseparator="
")
- print(code, lang,info, flush=True)
return highlight(code, lexer, formatter)
def render(self):
markdown_string = self.app.template_path.joinpath(self.template).read_text()
@@ -37,11 +37,12 @@ class MarkdownRenderer(HTMLRenderer):
return markdown(markdown_string)
-@functools.cache
+
def render_markdown_sync(app, markdown_string):
renderer = MarkdownRenderer(app,None)
markdown = Markdown(renderer=renderer)
return markdown(markdown_string)
+@time_cache_async(120)
async def render_markdown(app, markdown_string):
return render_markdown_sync(app,markdown_string)
\ No newline at end of file
diff --git a/src/snek/templates/about.md b/src/snek/templates/about.md
index c28e9d0..0b43fb4 100644
--- a/src/snek/templates/about.md
+++ b/src/snek/templates/about.md
@@ -14,56 +14,3 @@ I made several design choices:
- !DRY for HMTL/jinja2 templates. For templates Snek does prefer to repeat itself to implement exceptions for a page easier. For Snek it's preffered do a few updates instead of maintaining a complex generic system that requires maintenance regarding templates.
- No existing chat backend like `inspircd` (Popular decent IRC server written in the language of angels) because I prefer to know what is exactly going on above performance and concurrency limit. Also, this approach reduces as networking layer / gateway layer.
-# Some internals
-
-A few examples of how the system framework works.
-
-## How to create a user
-```python
-# Save user to the table named 'user'
-# Password gets sha256 encrypted with default a salt string
-# of the snek.system.security module.
-
-new_user_object = await app.service.user.register(
- username="retoor",
- password="retoorded"
-)
-```
-
-## Encrypt string
-```python
-from snek.system import security
-
-# Support for both utf and bytes.
-var1 = security.encrypt("data")
-var2 = security.encrypt(b"data")
-
-# Is correct:
-assert(var1 == var2)
-```
-
-## How to create a basic HTML / Markdown view
-```python
-from snek.system.view import BaseView
-
-class IndexView(BaseView):
-
- async def get(self):
- # The render function supports markdown.
- # It will render with syntax highlighting.
- # Just use the .md file extension in the file name.
- return await self.render("index.html")
-```
-## How to create a FormView
-```python
-from snek.system.view import BaseFormView
-from snek.form.register import RegisterForm
-
-class RegisterFormView(BaseFormView):
-
- form = RegisterForm
-```
-## How to register a class view
-```python
-app.routes.add_view("/your-page.html", YourViewClass)
-```
\ No newline at end of file
diff --git a/src/snek/templates/index.html b/src/snek/templates/index.html
index 8157f3d..ad02a6a 100644
--- a/src/snek/templates/index.html
+++ b/src/snek/templates/index.html
@@ -15,7 +15,8 @@
Or
Design choices
- See web Application so far
+ App preview
+ API docs