v0.1
This commit is contained in:
parent
e5adfa2d64
commit
8eea39ea07
13
README.md
Normal file
13
README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# squip_notes
|
||||
|
||||
! Work in progress !
|
||||
|
||||
This is a *very* basic notes-taking program. It uses python with flask and pickle, to give a really light and simple web interface for note taking.
|
||||
|
||||

|
||||
|
||||
## Future features
|
||||
* Allow for notes modification
|
||||
* Markdown interface
|
||||
* A squirrel ascii picture somewhere in the page :3
|
||||
* Less ugly colors and font
|
BIN
squipnotes.png
Normal file
BIN
squipnotes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
#coding: utf-8
|
||||
from flask import Flask, render_template, Markup, request
|
||||
import datetime, time
|
||||
from os.path import exists
|
||||
import datetime, time, pickle
|
||||
|
||||
#!---------- squiNotes.py ----------
|
||||
# My notes-taking app
|
||||
@ -31,9 +32,9 @@ class note:
|
||||
"""
|
||||
rendered = f"""
|
||||
<hr>
|
||||
<div class="notetitle">{self.title}</div><br>
|
||||
<div class="notetitle">{Markup.escape(self.title)}</div><br>
|
||||
<div class="notetime">Created : {self.rendertime(self.createtime)} Modified : {self.rendertime(self.modtime)}</div><br>
|
||||
<div class="notetext">{self.text}</div><br>"""
|
||||
<div class="notetext">{Markup.escape(self.text)}</div><br>"""
|
||||
return Markup(rendered)
|
||||
|
||||
def __str__(self):
|
||||
@ -48,35 +49,48 @@ def catnotes(notelist: list):
|
||||
final += note.flaskrender()
|
||||
|
||||
return final
|
||||
|
||||
def dumpnotes(notes):
|
||||
"""
|
||||
Get our notes list and save them as pickle to notes.pickle
|
||||
"""
|
||||
with open('notes.pickle', 'wb') as mpf:
|
||||
pickle.dump(notes, mpf)
|
||||
|
||||
return True
|
||||
|
||||
def getnotes():
|
||||
"""
|
||||
Get our notes from the file notes.pickle
|
||||
"""
|
||||
if exists("./notes.pickle"):
|
||||
with open('notes.pickle', 'rb') as mpf:
|
||||
notes = pickle.load(mpf)
|
||||
else:
|
||||
notes = []
|
||||
|
||||
return notes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------! MAIN
|
||||
app = Flask(__name__)
|
||||
|
||||
note1 = note(createtime=1647435623, modtime=1647435682, title="I love coffee", text="I love coffee. It is hot and delicious.")
|
||||
|
||||
note2 = note(createtime=1647435879, modtime=1647435999, title="I wanna go home", text="At first it was like dream, and then O I want to go home")
|
||||
|
||||
#Sort the notes ! Oldest first !
|
||||
global notes
|
||||
notes = [note1, note2]
|
||||
notes = sorted(notes, key=lambda note: note.modtime, reverse=True)
|
||||
|
||||
@app.route('/')
|
||||
def homepage():
|
||||
return render_template("homepage.html", nr = catnotes(notes))
|
||||
@app.route('/', methods=['GET'])
|
||||
def render():
|
||||
return render_template("homepage.html", nr = catnotes(getnotes()))
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
def newnote():
|
||||
def homepage():
|
||||
notetitle = request.form['title']
|
||||
notetext = request.form['text']
|
||||
rightnow = int(time.time())
|
||||
newnote = note(createtime=rightnow, modtime=rightnow, title=notetitle, text=notetext)
|
||||
notes = getnotes()
|
||||
notes.append(newnote)
|
||||
notes = sorted(notes, key=lambda note: note.modtime, reverse=True)
|
||||
homepage()
|
||||
|
||||
dumpnotes(notes)
|
||||
return render_template("homepage.html", nr = catnotes(getnotes()))
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user