get management routes up

main
lza_menace 2 years ago
parent 637f213d4a
commit 9828b767b3

@ -14,7 +14,7 @@ shell:
FLASK_SECRETS=config.py QUART_APP="flipbook:create_app()" .venv/bin/quart shell
dev:
FLASK_SECRETS=config.py QUART_APP="flipbook:create_app()" QUART_ENV=development .venv/bin/python3 run.py
FLASK_SECRETS=config.py QUART_APP="flipbook:create_app()" QUART_ENV=development DEBUG=True .venv/bin/python3 run.py
prod:
FLASK_SECRETS=config.py QUART_APP="flipbook:create_app()" QUART_ENV=production .venv/bin/hypercorn run

@ -1 +1,9 @@
# web3-flipbook
# web3-flipbook
| route | reason |
| ------------------ | ------------------ |
| / | show flipbook of all images rendered |
| /api/v1 | routes for authenticating, establishing sessions, and fetching data |
| /logout | clear session |
| /manage | user dashboard to see their owned tokens and uploaded images |
| /manage/upload | image uploading form |

@ -16,6 +16,7 @@ def create_app():
app = Quart(__name__)
app.config.from_envvar('FLASK_SECRETS')
login_manager = LoginManager(app)
login_manager.login_view = 'meta.index'
login_manager.logout_view = 'meta.logout'
@login_manager.user_loader
@ -26,10 +27,11 @@ def create_app():
@app.before_serving
async def startup():
from flipbook.routes import meta, api
from flipbook.routes import meta, api, manage
from flipbook import filters
await setup_db(app)
app.register_blueprint(meta.bp)
app.register_blueprint(manage.bp)
app.register_blueprint(api.bp)
app.register_blueprint(filters.bp)
# app.register_blueprint(cli.bp)

@ -1,5 +1,4 @@
import json
from secrets import token_urlsafe
from quart import Blueprint, jsonify, request
from flask_login import current_user

@ -0,0 +1,15 @@
from quart import Blueprint, render_template, request, redirect, url_for, flash
from flask_login import login_required
bp = Blueprint('manage', 'manage', url_prefix='/manage')
@bp.route('')
@login_required
async def index():
return await render_template('manage.html')
@bp.route('/upload', methods=['GET', 'POST'])
@login_required
async def upload():
return await render_template('upload.html')

@ -17,14 +17,4 @@ async def logout():
otherwise, redirect to peel off args and go home.
"""
logout_user()
if 'type' in request.args:
if request.args['type'] == 'accountsChanged':
flash('Metamask accounts have been changed, logging you out.', 'info')
if 'next' in request.args:
next_url = request.args['next']
if next_url.startswith('/'):
return redirect(next_url)
else:
return redirect(url_for('meta.index'))
return redirect(url_for('meta.index'))

@ -4,6 +4,7 @@
<ul>
<li><a href="/">Home</a></li>
{% if current_user.is_authenticated %}
<li><a href="{{ url_for('manage.index') }}" class="button">Manage</a></li>
<li><a href="{{ url_for('meta.logout') }}" class="button">Logout</a></li>
{% else %}
<li><a href="#" id="connectWallet" class="button">Connect</a></li>

@ -0,0 +1,4 @@
{% extends 'base.html' %}
{% block content %}
<p>manage</p>
{% endblock %}

@ -0,0 +1,4 @@
{% extends 'base.html' %}
{% block content %}
<p>upload</p>
{% endblock %}

@ -4,4 +4,4 @@ from flipbook.factory import create_app
app = create_app()
if __name__ == '__main__':
app.run(use_reloader=True)
app.run()

Loading…
Cancel
Save