Last update: 23 November 2019 Updated by: Muhammad Hafiz Maulana (1906350742) Kelas E """ from budayaKB_model import BudayaItem, BudayaCollection from flask import Flask, request, render_template, redirect, flash app = Flask(__name__) app.secret_key = "tp4" #inisialisasi objek budayaData databasefilename = "" budayaData = BudayaCollection() #merender tampilan default(index.html) @app.route('/') def index(): return render_template("index.html") # Bagian ini adalah implementasi fitur Impor Budaya, yaitu: # - merender tampilan saat menu Impor Budaya diklik # - melakukan pemrosesan terhadap isian form setelah tombol "Import Data" diklik # - menampilkan notifikasi bahwa data telah berhasil diimport @app.route('/imporBudaya', methods=['GET', 'POST']) def importData(): if request.method == "GET":
from budayaKB_model import BudayaCollection from flask import Flask, request, render_template from flask_wtf import FlaskForm from flask_wtf.file import FileRequired from wtforms import StringField, SubmitField, SelectField, FileField from wtforms.validators import InputRequired, URL # Set some required config for flask app = Flask(__name__) app.secret_key = "tp4" # Initialize model object database = BudayaCollection() class ImportForm(FlaskForm): """Form used for import function""" filename = FileField('File Name', validators=[FileRequired()], render_kw={'class': "file-input"}) submit = SubmitField('Import', render_kw={'class': "button is-fullwidth is-hover is-primary "}) class EditForm(FlaskForm): """Form used for add and change function""" name = StringField('Name', validators=[InputRequired()], render_kw={'class': "input"}) type = StringField('Type', validators=[InputRequired()], render_kw={'class': "input"}) prov = StringField('Province', validators=[InputRequired()], render_kw={'class': "input"}) url = StringField('Reference URL', validators=[InputRequired(), URL()], render_kw={'class': "input"}) submit = SubmitField('Submit', render_kw={'class': "button is-fullwidth is-hover is-primary"}) class SearchForm(FlaskForm):