コード例 #1
0
def display_a_question(question_id):

    table = data_manager.read_csv('question.csv')
    answer_table = data_manager.read_csv('answer.csv')
    reverse_timeline = reversed(list(answer_table))
    question_line = util.find_line(table, question_id, 0)
    question_title = question_line[4]
    question_msg = question_line[5]

    answer_line = util.find_line(answer_table, question_id, 2)
    answer = answer_line[4]

    return render_template('display_a_question.html',
                           answer_table=reverse_timeline,
                           answer=answer,
                           line=answer_line,
                           table=table,
                           question_id=question_id,
                           title=question_title,
                           question_msg=question_msg)
コード例 #2
0
def add_new_answer(question_id):
    if request.method == 'GET':
        return render_template('post_answers.html')
    elif request.method == 'POST':
        answers = data_manager.read_csv("answer.csv")
        form = request.form.to_dict()
        form_list = [
            util.add_new_id(answers),
            int(time.time()), 0, 0, form['post_answers'], answers, ''
        ]
        answers.append(form_list)
        data_manager.write_csv("answers.csv", answers)
        return redirect('/list')
コード例 #3
0
def add_question():
    if request.method == "GET":
        return render_template("ask_question.html")
    elif request.method == "POST":
        questions = data_manager.read_csv("question.csv")
        form = request.form.to_dict()
        form_list = [
            util.add_new_id(questions),
            int(time.time()), 0, 0, form['questiontitle'],
            form['question_body'], ''
        ]
        questions.append(form_list)
        data_manager.write_csv("question.csv", questions)
        return redirect("/")
コード例 #4
0
def admin():
    dict = data_manager.read_csv('Data/orders.csv')
    fieldnames = ["Order ID","Product ID","Quantity","Total price","Currency"]
    return render_template("admin.html", file=dict, fieldnames=fieldnames)
コード例 #5
0
def products():
    dict = data_manager.read_csv('Data/products.csv')
    fieldnames = ["ID", "Product Name", "Product description", "Price", "Currency", "Available units"]
    return render_template("products.html", file=dict, fieldnames=fieldnames)
コード例 #6
0
ファイル: app.py プロジェクト: bichu136/Wibu_Web
import flask as flk
from flask import request,redirect,send_from_directory,Response
import json
import os
from data_manager import DataManager,read_csv
# import keras
# import keras.layers as layers
# import keras.models as models
app = flk.Flask(__name__)
data_manager = read_csv('processed_data.csv')
@app.route("/")
def index():
    rows,_,ranked_list,random_list = data_manager.get_rows_and_list_page_for_list(1)
    return flk.render_template("index.html",rows=rows,ranked_list=ranked_list.to_dict('records'),random_list=random_list.to_dict('records'))


@app.route("/aboutme")
def aboutme():
    return flk.render_template("aboutme.html")


@app.route("/contact")
def contact():
    return flk.render_template("contact.html")


@app.route("/film/<film_name>")
def anime_film(film_name):
    title,genres,episodes,year,content,image_url = data_manager.get_anime_info_by_name(film_name)
    return flk.render_template("anime-info.html",film_name=title,content=content,episodes=episodes,genres=genres,year=year,image_url=image_url)
コード例 #7
0
def question_table():
    table = data_manager.read_csv('question.csv')
    reversed_table = reversed(table)
    return render_template("list.html", table=reversed_table)