47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from flask import Blueprint, render_template, request, flash, jsonify
|
|
from .models import Note
|
|
from . import db
|
|
import json
|
|
|
|
views = Blueprint('views', __name__)
|
|
|
|
|
|
@views.route('/', methods=['GET', 'POST'])
|
|
def home():
|
|
'''if request.method == 'POST':
|
|
note = request.form.get('note')
|
|
|
|
if len(note) < 1:
|
|
flash('Note is too short!', category='error')
|
|
else:
|
|
new_note = Note(data=note, user_id=current_user.id)
|
|
db.session.add(new_note)
|
|
db.session.commit()
|
|
flash('Note added!', category='success')'''
|
|
|
|
return render_template("home.html")
|
|
|
|
@views.route('/sites')
|
|
def sites():
|
|
return render_template("sites.html")
|
|
|
|
@views.route('/about')
|
|
def about():
|
|
return render_template("about.html")
|
|
|
|
@views.route('/game')
|
|
def game():
|
|
return render_template("game.html")
|
|
|
|
'''@views.route('/delete-note', methods=['POST'])
|
|
def delete_note():
|
|
note = json.loads(request.data)
|
|
noteId = note['noteId']
|
|
note = Note.query.get(noteId)
|
|
if note:
|
|
if note.user_id == current_user.id:
|
|
db.session.delete(note)
|
|
db.session.commit()
|
|
|
|
return jsonify({})'''
|