from __future__ import absolute_import, division, print_function import json import yaml import flask from wqflask import app from flask import render_template, request from wqflask import search_results from wqflask.show_trait import DataEditingPage from wqflask.correlation import CorrelationPage from wqflask.dataSharing import SharingInfo, SharingInfoPage from base import webqtlFormData from pprint import pformat as pf print("latest blue") @app.route("/") def index_page(): print("Sending index_page") return render_template("index_page.html") @app.route("/data_sharing") def data_sharing(): print("In data_sharing") fd = webqtlFormData.webqtlFormData(request.args) print("1Have fd") sharingInfoObject = SharingInfo.SharingInfo(request.args['GN_AccessionId'], None) info, htmlfilelist = sharingInfoObject.getBody(infoupdate="") print("type(htmlfilelist):", type(htmlfilelist)) htmlfilelist = htmlfilelist.encode("utf-8") #template_vars = SharingInfo.SharingInfo(request.args['GN_AccessionId'], None) print("1 Made it to rendering") return render_template("data_sharing.html", info=info, htmlfilelist=htmlfilelist) @app.route("/search") def search(): if 'info_database' in request.args: print("Going to sharing_info_page") template_vars = sharing_info_page() if template_vars.redirect_url: print("Going to redirect") return flask.redirect(template_vars.redirect_url) else: return render_template("data_sharing.html", **template_vars.__dict__) else: the_search = search_results.SearchResultPage(request.args) return render_template("search_result_page.html", **the_search.__dict__) @app.route("/whats_new") def whats_new(): #variables = whats_new.whats_new() with open("/home/sam/gene/wqflask/wqflask/yaml_data/whats_new.yaml") as fh: contents = fh.read() yamilized = yaml.safe_load(contents) news_items = yamilized['news'] for news_item in news_items: print("\nnews_item is: %s\n" % (news_item)) return render_template("whats_new.html", news_items=news_items) @app.route("/show_trait") def show_trait(): # Here it's currently too complicated not to use an fd that is a webqtlFormData fd = webqtlFormData.webqtlFormData(request.args) #template_vars = show_trait_page.ShowTraitPage(fd) template_vars = DataEditingPage.DataEditingPage(fd) template_vars.js_data = json.dumps(template_vars.js_data) print("show_trait template_vars:", pf(template_vars.__dict__)) return render_template("trait_data_and_analysis.html", **template_vars.__dict__) @app.route("/corr_compute", methods=('POST',)) def corr_compute(): #print("In corr_compute, request.args is:", pf(request.form)) fd = webqtlFormData.webqtlFormData(request.form) print("Have fd") template_vars = CorrelationPage.CorrelationPage(fd) print("Made it to rendering") return render_template("correlation_page.html", **template_vars.__dict__) # Todo: Can we simplify this? -Sam def sharing_info_page(): print("In sharing_info_page") fd = webqtlFormData.webqtlFormData(request.args) print("2Have fd") template_vars = SharingInfoPage.SharingInfoPage(fd) print("2 Made it to rendering") return template_vars