-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (38 loc) · 1.29 KB
/
app.py
File metadata and controls
45 lines (38 loc) · 1.29 KB
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
from flask import Flask, render_template, redirect, url_for
import frontmatter
import os
import mistune
app = Flask(__name__)
markdown = mistune.create_markdown()
@app.route('/')
def home():
tiles = []
for filename in os.listdir('offerings'):
if filename.endswith('.md'):
with open(f'offerings/{filename}') as f:
post = frontmatter.load(f)
tiles.append({
'title': post['TITLE'],
'summary': post['SUMMARY'],
'icon': post['ICON'],
'url': filename[:-3] # remove .md
})
return render_template('home.html', tiles=tiles)
@app.route('/<name>')
def offering(name):
with open(f'offerings/{name}.md') as f:
post = frontmatter.load(f)
post.content = markdown(post.content)
return render_template('offering.html', post=post)
@app.route('/submit-api-key', methods=['POST'])
def submit_api_key():
api_key = ""
# Do something with the API key...
# Then redirect to the "in-progress" page
return redirect(url_for('in_progress'))
@app.route('/in-progress')
def in_progress():
# Render your 'in-progress' page here
return render_template('progress.html')
if __name__ == '__main__':
app.run(debug=True, port=3000)