aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMart Raudsepp <leio@gentoo.org>2016-11-23 01:54:03 +0200
committerMart Raudsepp <leio@gentoo.org>2016-11-23 01:58:04 +0200
commit971600fca7c3fd6599d4133d10e32d27d3cfc6e5 (patch)
tree8643b701fa5d074797f30fffcaa413f5bcc82cf9 /backend/__init__.py
parentAdd parsed project members to the result dict (diff)
downloadgrumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.tar.gz
grumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.tar.bz2
grumpy-971600fca7c3fd6599d4133d10e32d27d3cfc6e5.zip
Make the dummy initial web frontend pretty
Now uses extra Flask-Classy dependency for nicer routing and organization. Stylesheet is Gentoo Tyrian loaded from standard CDN location. Reorganizes some of frontend to frontend module, which necessitates telling Flask it's "frontend", not "backend" (for templates to work without passing custom paths). If reorganization goes this route and completes, all the flask parts should end up in frontend module, making this hack obsolete. Though backend might want to use Flask-Sqlalchemy too, so needing the Flask app object, but not sure yet.
Diffstat (limited to 'backend/__init__.py')
-rw-r--r--backend/__init__.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/backend/__init__.py b/backend/__init__.py
index b03432b..46a4007 100644
--- a/backend/__init__.py
+++ b/backend/__init__.py
@@ -1,20 +1,12 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
-app = Flask(__name__)
-app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///grumpy.db" # FIXME: configuration support
+app = Flask("frontend") # FIXME: Finish rearranging frontend/backend modules properly instead of pretending to be frontend in backend/__init__ because jinja templates are looked for from <what_is_passed_here>/templates
+app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///../backend/grumpy.db" # FIXME: configuration support; weird ../ because of claiming we are "frontend" to Flask and want to keep the path the same it was before for now. But this problem should go away with config, at least for postgres :)
db = SQLAlchemy(app)
-from .lib import models
-
-
-@app.route("/")
-def hello_world():
- categories = models.Category.query.all()
- text = ""
- for cat in categories:
- text += "<b>%s</b>: %s<br>" % (cat.name, cat.description)
- return "Hello World! These are the package categories I know about:<br>%s" % text
+from frontend import *
+GrumpyView.register(app)
__all__ = ["app", "db"]