diff --git a/Makefile b/Makefile index de4eb6b..3450eae 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 7aa9f8f..c4f4fa9 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ -# web3-flipbook \ No newline at end of file +# 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 | \ No newline at end of file diff --git a/flipbook/factory.py b/flipbook/factory.py index 46ebc4f..fa765e7 100644 --- a/flipbook/factory.py +++ b/flipbook/factory.py @@ -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) diff --git a/flipbook/routes/api.py b/flipbook/routes/api.py index c6bcf8e..06473f3 100644 --- a/flipbook/routes/api.py +++ b/flipbook/routes/api.py @@ -1,5 +1,4 @@ import json -from secrets import token_urlsafe from quart import Blueprint, jsonify, request from flask_login import current_user diff --git a/flipbook/routes/manage.py b/flipbook/routes/manage.py new file mode 100644 index 0000000..21d6974 --- /dev/null +++ b/flipbook/routes/manage.py @@ -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') \ No newline at end of file diff --git a/flipbook/routes/meta.py b/flipbook/routes/meta.py index 88c9adc..086e28e 100644 --- a/flipbook/routes/meta.py +++ b/flipbook/routes/meta.py @@ -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')) \ No newline at end of file diff --git a/flipbook/templates/includes/header.html b/flipbook/templates/includes/header.html index bbc01b4..998607d 100644 --- a/flipbook/templates/includes/header.html +++ b/flipbook/templates/includes/header.html @@ -4,6 +4,7 @@
manage
+{% endblock %} \ No newline at end of file diff --git a/flipbook/templates/upload.html b/flipbook/templates/upload.html new file mode 100644 index 0000000..8109d97 --- /dev/null +++ b/flipbook/templates/upload.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block content %} +upload
+{% endblock %} \ No newline at end of file diff --git a/run.py b/run.py index f6be6ae..57f1bf8 100644 --- a/run.py +++ b/run.py @@ -4,4 +4,4 @@ from flipbook.factory import create_app app = create_app() if __name__ == '__main__': - app.run(use_reloader=True) + app.run()