-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
62 lines (48 loc) · 1.42 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from flask import Flask, render_template
from flaskext.markdown import Markdown
import contentful
from rich_text_renderer import RichTextRenderer
from rich_text_renderer.base_node_renderer import BaseNodeRenderer
from rich_text_renderer.null_renderer import NullRenderer
import os
from dotenv import load_dotenv
load_dotenv()
from custom_renders import (
locationBlockEntryRenderer,
buttonEntryRenderer,
BaseInlineRenderer,
BaseBlockEntryRenderer,
)
SPACE_ID = os.environ.get("SPACE_ID")
DELIVERY_API_KEY = os.environ.get("DELIVERY_API_KEY")
API_URL = os.environ.get("API_URL")
MAP_KEY = os.environ.get("MAP_KEY")
DEBUG_STATUS = os.environ.get("DEBUG_STATUS")
ENV = os.environ.get("ENV")
client = contentful.Client(SPACE_ID, DELIVERY_API_KEY, API_URL, environment=ENV)
BaseBlockEntryRenderer.__RENDERERS__ += [
locationBlockEntryRenderer,
buttonEntryRenderer,
]
renderer = RichTextRenderer(
{
"embedded-entry-block": BaseBlockEntryRenderer,
"embedded-entry-inline": BaseInlineRenderer,
}
)
app = Flask(__name__)
Markdown(app)
@app.route("/")
def home_page():
entry = client.entry("1l3EHYzPbgf9UUV0oEyTDs")
return render_template(
"home.html",
renderer=renderer,
title=entry.page_title,
page_components=entry.page_component,
client=client,
MAP_KEY=MAP_KEY,
)
if __name__ == "__main__":
app.debug = DEBUG_STATUS
app.run()