Commits

Chris Mutel committed 3b1009f

Additional functionality to get web UI running

Comments (0)

Files changed (3)

bw2ui/bin/bw2-web.py

 # -*- coding: utf-8 -*
 from bw2ui.web import bw2webapp
 
-bw2webapp.run()
+bw2webapp.run(debug=True)
 # -*- coding: utf-8 -*
+import base64
 from brightway2 import config, databases, methods, Database, Method
+from bw2calc import LCA
 from flask import Flask, url_for, render_template
 
 app = Flask(__name__)
     print context
     return "Success"
     return render_template("index.html", **context)
+
+
+@app.route('/calculate/lca')
+@app.route('/calculate/lca/<process>/<method>')
+def lca(process=None, method=None):
+    context = template_context()
+    if process:
+        method = eval(base64.urlsafe_b64decode(str(method)), None, None)
+        process = eval(base64.urlsafe_b64decode(str(process)), None, None)
+        lca = LCA(process, method)
+        lca.lci()
+        lca.lcia()
+        return render_template("lca.html", **context)
+    else:
+        return "No parameters"
   name='bw2ui',
   version="0.1",
   packages=["bw2ui", "bw2ui.web"],
-  package_data={'bw2ui': ["web/static/*/*.*", "web/templates/*/*.html"]},
+  package_data={'bw2ui': ["web/static/*/*.*", "web/templates/*.*", "web/templates/*/*.*"]},
   author="Chris Mutel",
   author_email="cmutel@gmail.com",
   license=open('LICENSE.txt').read(),