mirror of
https://github.com/sigmasternchen/Diary
synced 2025-03-15 07:08:56 +00:00
I CAN HAZ PYTHON, I CAN HAZ INDENTS
This commit is contained in:
parent
0d22803179
commit
9b79ba2719
2 changed files with 16 additions and 1 deletions
10
server.py
10
server.py
|
@ -49,6 +49,16 @@ def logout():
|
|||
setuser('','')
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/diary/?new',methods=['POST'])
|
||||
def newdiary():
|
||||
if not loggedin():
|
||||
abort(403)
|
||||
d=Diary(session['id'], request.form['name'])
|
||||
db.add(d)
|
||||
db.commit()
|
||||
return redirect(url_for('diary', name=request.form['name']))
|
||||
|
||||
|
||||
@app.route('/diary/<name>')
|
||||
def diary(name=''):
|
||||
if not loggedin():
|
||||
|
|
|
@ -7,7 +7,12 @@
|
|||
<script src="{{ url_for('static',filename='script.js') }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p><a href="{{ url_for('logout') }}">Logout</a></p>
|
||||
<p>
|
||||
<a href="{{ url_for('logout') }}">Logout</a>
|
||||
<form method="post" action="{{ url_for('newdiary')}}">
|
||||
New diary: <input type="text" name="name" placeholder="name of diary"><input type="submit">
|
||||
</form>
|
||||
</p>
|
||||
<ul>
|
||||
{% for d in diaries %}
|
||||
<li>
|
||||
|
|
Loading…
Reference in a new issue