def index(): ''' index page to display the date selection form ''' form = DateForm() if form.validate_on_submit(): date = form.date.data.strftime(DATE_FORMAT) return redirect(url_for('view_prediction', pred_date=date)) return render_template('date_picker.html', form=form)
def main(): form = DateForm() dates = [] for date in Course.query.all(): if date.date not in dates: dates.append(date.date) if form.validate_on_submit(): url = f"http://www.cbr.ru/scripts/XML_daily.asp?date_req={form.date.data}" res = requests.get(url) tree = ET.fromstring(res.text) for valute in tree.findall("Valute"): course = Course(num_code=valute.find("NumCode").text, char_code=valute.find("CharCode").text, nominal=valute.find("Nominal").text, name=valute.find("Name").text, value=valute.find("Value").text, date=form.date.data) db.session.add(course) db.session.commit() return redirect(f"/{form.date.data}") return render_template("index.html", form=form, course=Course.query.all(), dates=dates)
def edit_date(id): if not current_user.is_admin: #throw a 403 error if the user is not an admin user abort(403) add_date = False dates = ImportantDate.query.order_by(ImportantDate.date_time) date = ImportantDate.query.get_or_404(id) form = DateForm(obj=date) if form.validate_on_submit(): date.title = form.title.data date.info = form.info.data date.date_time = form.date.data db.session.commit() flash('You have sucessfully edited the date.', 'success') return redirect(url_for('home.admin_dashboard')) form.title.data = date.title form.info.data = date.info form.date.data = date.date_time return render_template('admin/edit-dates.html', title="Edit Date", action="Edit", add_date=add_date, form=form, date=date, dates=dates)
def logs(): form = DateForm() ids = [i for i in range(len(boxes))] form.box.choices = list(zip(ids, boxes)) if form.validate_on_submit(): print("validated") dt = str(form.dt.data) date = dt.replace('-', '') box_id = form.box.data box = [f[1] for f in form.box.choices if f[0] == box_id] severity_id = form.severity.data severity = [f[1] for f in form.severity.choices if f[0] == severity_id] payload = {'date': date, 'severity': severity, 'box': box} r = requests.get('http://217.73.28.16:5002/syslog', params=payload) print(r.url) logs = json.loads(r.text) return render_template('logs.html', logs=logs, form=form, conf=conf) else: date = datetime.datetime.now().strftime("%Y%m%d") # Uncomment if you want to allow default view #severity = all #box = six #payload = { 'date':date, 'severity':severity, 'box':box } #r = requests.get('http://217.73.28.16:5002/syslog', params=payload) #logs = json.loads(r.text) logs = {} return render_template('logs.html', logs=logs, form=form, conf=conf)
def DisplayTopTalkers(): form = DateForm(csrf_enabled=False) if form.validate_on_submit(): jsonChart = analytics_engine.getfwTopTalkers(form.fromdate.data.strftime('%Y-%m-%d'), form.todate.data.strftime('%Y-%m-%d')) return render_template('DisplayTableAndCharts.html', sankey=True, jsonTable=jsonChart, jsonChart=jsonChart) return render_template("dateForm.html", form=form)
def journal(): form = DateForm() if request.method == 'POST' and form.validate_on_submit(): spot = SpotSQL() data = spot.get_user_songs(sp.get_user_id()) return render_template('journal.html', data=generate_chart( request.cookies.get('prevEmotion')), labels=labels) return render_template('journal.html')
def search(): # Data Collectors mf = MonthForm() df = DateForm() cf = ContestForm() emptyList = [" "] conn = sqlite3.connect( "/Users/broeking/Desktop/T.R.E.A./src/Database/trea.db") cursor = conn.cursor() # Executes if we know contest if cf.validate_on_submit(): cursor.execute('SELECT * FROM lineups where month = "' + session['month'] + '" AND date = "' + session['date'] + '" AND contest = "' + cf.contest.data + '"') session['contest'] = cf.contest.data lineups = [ dict(id=row[0], Rank=row[1], EntryName=row[2], Points=row[3], Lineup=row[4], SP1=row[5], SP2=row[6], C=row[7], First=row[8], Second=row[9], Third=row[10], Short=row[11], OF1=row[12], OF2=row[13], OF3=row[14], blank=row[15], month=row[16], date=row[17], contest=row[18]) for row in cursor.fetchall() ] # return redirect(url_for('lineup', lineps=lineups)) return render_template('search.html', months=emptyList, dates=emptyList, contests=emptyList, mf=None, df=None, cf=None, lineups=lineups) # Executes if we know date if df.validate_on_submit(): cursor.execute('SELECT DISTINCT contest FROM lineups where month = "' + session['month'] + '" AND date = ' + df.date.data) session['date'] = df.date.data contests = [item[0] for item in cursor.fetchall()] return render_template('search.html', months=emptyList, dates=emptyList, contests=contests, mf=None, df=None, cf=cf) # Executes if we know the month if mf.validate_on_submit(): cursor.execute('SELECT DISTINCT date FROM lineups where month = "' + mf.month.data + '"') session['month'] = mf.month.data dates = [item[0] for item in cursor.fetchall()] return render_template('search.html', months=emptyList, dates=dates, contests=emptyList, mf=None, df=df, cf=None) # Initial return cursor.execute('SELECT DISTINCT month FROM lineups') months = [item[0] for item in cursor.fetchall()] return render_template('search.html', months=months, dates=emptyList, contests=emptyList, mf=mf, df=None, cf=None)
def vegas(): # Data Collectors mf = MonthForm() df = DateForm() cf = ContestForm() emptyList = [" "] conn = sqlite3.connect( "/Users/broeking/Desktop/T.R.E.A./src/Database/trea.db") cursor = conn.cursor() # Executes if we know contest if cf.validate_on_submit(): # Collect the Ownerships and Points for that day cursor.execute('SELECT * FROM ownerships where month = "' + session['month'] + '" AND date = "' + session['date'] + '" AND contest = "' + cf.contest.data + '"') session['contest'] = cf.contest.data ownerships = [ dict(id=row[0], player=row[1], drafted=row[2], FPTS=row[3], month=row[4], date=row[5], contest=row[6]) for row in cursor.fetchall() ] # Collect the lines for that day cursor.execute('SELECT * FROM lines where date = "' + session['date'] + '" AND year = "2017"') lines = [ dict(id=row[0], Away_Team=row[1], Home_Team=row[2], Away_Starter=row[3], Home_Starter=row[4], Start_Time=row[5], Away_Final_Score=row[6], Home_Final_Score=row[7], Away_Opening=row[8], Home_Opening=row[9], Away_Westgate=row[10], Home_Westgate=row[11], Away_Mirage=row[12], Home_Mirage=row[13], Away_Station=row[14], Home_Station=row[15], Away_Pinnacle=row[16], Home_Pinnacle=row[17], Away_SIA=row[18], Home_SIA=row[19], Away_SBG=row[20], Home_SBG=row[21], Away_BetUS=row[22], Home_BetUS=row[23], Away_BetPhoenix=row[24], Home_BetPhoenix=row[25], Away_EasyStreet=row[26], Home_EasyStreet=row[27], Away_Bovada=row[28], Home_Bovada=row[29], Away_Jazz=row[30], Home_Jazz=row[31], Away_Sportsbet=row[32], Home_Sportsbet=row[33], Away_Bookmaker=row[34], Home_Bookmaker=row[35], Away_DSI=row[36], Home_DSI=row[37], Away_AceSport=row[38], Home_AceSport=row[39], date=row[40], year=row[41]) for row in cursor.fetchall() ] # return redirect(url_for('lineup', lineps=lineups)) return render_template('vegas.html', months=emptyList, dates=emptyList, contests=emptyList, mf=None, df=None, cf=None, ownerships=ownerships, lines=lines) # Executes if we know date if df.validate_on_submit(): cursor.execute( 'SELECT DISTINCT contest FROM ownerships where month = "' + session['month'] + '" AND date = ' + df.date.data) session['date'] = df.date.data contests = [item[0] for item in cursor.fetchall()] return render_template('lines_search.html', months=emptyList, dates=emptyList, contests=contests, mf=None, df=None, cf=cf) # Executes if we know the month if mf.validate_on_submit(): cursor.execute('SELECT DISTINCT date FROM ownerships where month = "' + mf.month.data + '"') session['month'] = mf.month.data dates = [item[0] for item in cursor.fetchall()] return render_template('lines_search.html', months=emptyList, dates=dates, contests=emptyList, mf=None, df=df, cf=None) # Initial return cursor.execute('SELECT DISTINCT month FROM ownerships') months = [item[0] for item in cursor.fetchall()] return render_template('lines_search.html', months=months, dates=emptyList, contests=emptyList, mf=mf, df=None, cf=None)