In app/routes.py
, define the routes for your application. We'll start with a simple homepage that allows users to create and view cheatsheets.
from flask import render_template, redirect, url_for, request
from app import app
cheatsheets = {}
@app.route('/')
def index():
return render_template('index.html', cheatsheets=cheatsheets)
@app.route('/create', methods=['GET', 'POST'])
def create_cheatsheet():
if request.method == 'POST':
title = request.form['title']
content = request.form['content']
cheatsheets[title] = content
return redirect(url_for('index'))
return render_template('create.html')