Current prod version
This commit is contained in:
parent
f52d98333e
commit
34c5300608
7 changed files with 32 additions and 11 deletions
|
|
@ -11,6 +11,7 @@ bp = Blueprint('auth', __name__, url_prefix='/auth')
|
|||
|
||||
@bp.route('/register', methods=('GET', 'POST'))
|
||||
def register():
|
||||
return "Admin only", 403
|
||||
if request.method == 'POST':
|
||||
username = request.form['username']
|
||||
password = request.form['password']
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from flaskr.auth import login_required
|
|||
from flaskr.db import get_db
|
||||
|
||||
import markdown
|
||||
import datetime
|
||||
|
||||
bp = Blueprint('blog', __name__)
|
||||
|
||||
|
|
@ -20,6 +21,8 @@ def index():
|
|||
).fetchall()
|
||||
posts = []
|
||||
for post in db_posts:
|
||||
if post['created'] > datetime.datetime.utcnow():
|
||||
continue
|
||||
post = dict(post)
|
||||
post['body'] = markdown.markdown(post['body'])
|
||||
posts.append(post)
|
||||
|
|
@ -74,19 +77,23 @@ def update(id):
|
|||
if request.method == 'POST':
|
||||
title = request.form['title']
|
||||
body = request.form['body']
|
||||
created = request.form['created']
|
||||
error = None
|
||||
|
||||
if not title:
|
||||
error = 'Title is required.'
|
||||
|
||||
if not created:
|
||||
error = "Created is required."
|
||||
|
||||
if error is not None:
|
||||
flash(error)
|
||||
else:
|
||||
db = get_db()
|
||||
db.execute(
|
||||
'UPDATE post SET title = ?, body = ?'
|
||||
'UPDATE post SET title = ?, body = ?, created = ?'
|
||||
' WHERE id = ?',
|
||||
(title, body, id)
|
||||
(title, body, created, id)
|
||||
)
|
||||
db.commit()
|
||||
return redirect(url_for('blog.index'))
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 73 B After Width: | Height: | Size: 101 KiB |
|
|
@ -1,6 +1,11 @@
|
|||
html { font-family: sans-serif; background: #eee; padding: 1rem; }
|
||||
body { max-width: 960px; margin: 0 auto; background: white; }
|
||||
h1 { font-family: serif; color: #377ba8; margin: 1rem 0; }
|
||||
h2 { color: #377ba8; margin: 1rem 0; }
|
||||
h3 { color: #377ba8; margin: 1rem 0; }
|
||||
h4 { color: #377ba8; margin: 1rem 0; }
|
||||
h5 { color: #377ba8; margin: 1rem 0; }
|
||||
h6 { color: #377ba8; margin: 1rem 0; }
|
||||
a { color: #377ba8; }
|
||||
hr { border: none; border-top: 1px solid lightgray; }
|
||||
nav { background: lightgray; display: flex; align-items: center; padding: 0 0.5rem; }
|
||||
|
|
@ -14,7 +19,12 @@ nav ul li a, nav ul li span, header .action { display: block; padding: 0.5rem; }
|
|||
.flash { margin: 1em 0; padding: 1em; background: #cae6f6; border: 1px solid #377ba8; }
|
||||
.post > header { display: flex; align-items: flex-end; font-size: 0.85em; }
|
||||
.post > header > div:first-of-type { flex: auto; }
|
||||
.post > header h1 { font-size: 1.5em; margin-bottom: 0; }
|
||||
.post > header h1 { margin-bottom: 0; }
|
||||
.post > h2 { margin-bottom: 0; }
|
||||
.post > h3 { margin-bottom: 0; }
|
||||
.post > h4 { margin-bottom: 0; }
|
||||
.post > h5 { margin-bottom: 0; }
|
||||
.post > h6 { margin-bottom: 0; }
|
||||
.post .about { color: slategray; font-style: italic; }
|
||||
.post .body { white-space: pre-line; }
|
||||
.content:last-child { margin-bottom: 0; }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<!doctype html>
|
||||
<title>{% block title %}{% endblock %} - Flaskr</title>
|
||||
<title>{% block title %}{% endblock %} - blogsparkinfinite</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon.png') }}">
|
||||
<nav>
|
||||
<h1>Flaskr</h1>
|
||||
<h1>blogsparkinfinite</h1>
|
||||
<ul>
|
||||
{% if g.user %}
|
||||
<li><span>{{ g.user['username'] }}</span>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
value="{{ request.form['title'] or post['title'] }}" required>
|
||||
<label for="body">Body</label>
|
||||
<textarea name="body" id="body">{{ request.form['body'] or post['body'] }}</textarea>
|
||||
<label for="created">Created</label>
|
||||
<input name="created" id="created"
|
||||
value="{{ request.form['created'] or post['created'] }}" required>
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
<hr>
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ dnspython==2.3.0
|
|||
email-validator==2.0.0.post2
|
||||
exceptiongroup==1.1.1
|
||||
Flask==2.3.2
|
||||
-e git+https://gitlab.com/pvtejas/based4tech.git@4be89bd767a7c5a84ab62fbf4ad924ae1af077f1#egg=flaskr
|
||||
# -e git+https://gitlab.com/pvtejas/based4tech.git@4be89bd767a7c5a84ab62fbf4ad924ae1af077f1#egg=flaskr
|
||||
gunicorn==20.1.0
|
||||
h11==0.14.0
|
||||
httpcore==0.17.0
|
||||
httptools==0.5.0
|
||||
httptools
|
||||
httpx==0.24.0
|
||||
idna==3.4
|
||||
iniconfig==2.0.0
|
||||
|
|
@ -20,20 +20,20 @@ itsdangerous==2.1.2
|
|||
Jinja2==3.1.2
|
||||
Markdown==3.4.3
|
||||
MarkupSafe==2.1.2
|
||||
orjson==3.8.11
|
||||
orjson
|
||||
packaging==23.1
|
||||
pluggy==1.0.0
|
||||
pyproject_hooks==1.0.0
|
||||
pytest==7.3.2
|
||||
python-dotenv==1.0.0
|
||||
python-multipart==0.0.6
|
||||
PyYAML==6.0
|
||||
# PyYAML==6.0
|
||||
sniffio==1.3.0
|
||||
tomli==2.0.1
|
||||
typing_extensions==4.5.0
|
||||
ujson==5.7.0
|
||||
ujson
|
||||
uvicorn==0.22.0
|
||||
uvloop==0.17.0
|
||||
uvloop
|
||||
watchfiles==0.19.0
|
||||
websockets==11.0.3
|
||||
Werkzeug==2.3.3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue