def xhr_sickbeard(): try: url = '%s/?cmd=future&sort=date' % (sickbeard_url()) result = urllib.urlopen(url).read() sickbeard = json.JSONDecoder().decode(result) compact_view = get_setting_value('sickbeard_compact') == '1' show_airdate = get_setting_value('sickbeard_airdate') == '1' if sickbeard['result'].rfind('success') >= 0: sickbeard = sickbeard['data'] for time in sickbeard: for episode in sickbeard[time]: episode['image'] = get_pic(episode['tvdbid'], 'banner') except: return render_template('sickbeard.html', sickbeard='', ) return render_template('sickbeard.html', url=sickbeard_url_no_api(), sickbeard=sickbeard, missed=sickbeard['missed'], today=sickbeard['today'], soon=sickbeard['soon'], later=sickbeard['later'], compact_view=compact_view, show_airdate=show_airdate, )
def blogedit(blogid): if 'logged_in' not in session: abort(403) if request.method == 'POST': title = request.form['title'].strip() text = request.form['blogpost'].strip() error = 0 if title == "": error = 1 flash("You must make a title","error") if text == "": error = 1 flash("You must make the blogpost","error") if 'Preview Blog' in request.form.values(): renderedblog = render_bbcode(text) return render_template("blogedit.html",blogid=blogid,title=title,blogpost=text,recover=1,preview="1",renderedblog=renderedblog) if error: return render_template('blogedit.html',blogid=blogid,title=title,blogpost=text,recover=1) g.db.execute(""" UPDATE post SET title=?, text=?, lastedit=? WHERE id=? """,(title,text,unixtime(),blogid)) g.db.commit() flash("You successfully changed your blogpost","message") return redirect(url_for('blogpost',blogid=blogid)) g.blog = query_db(""" SELECT * FROM post WHERE id=? """, [str(blogid)], True,False) return render_template('blogedit.html',blogid=blogid)
def index(): url_for('static', filename='logo.ico') if request.method == 'POST': #Check files that start with 'o-ide*' files = glob.glob("oide*") print(files) #Check if C was compiled if len(files) < 1: print("Compiling O...") compileO() #Run code code = request.form['code'] input = request.form['input'].replace('\r\n', '\n') if input is None: input = "" print('Got code:', code, 'input:', input) print('Running O code...') p = Popen(['./oide', '-e', code], stdout=PIPE, stderr=PIPE, stdin=PIPE, universal_newlines=True) output, error = p.communicate(input) #Output to IDE if p.returncode: print('Output:', output, 'error:', error) return render_template('error.html', code=code, input=input, error=error) else: print('Output:', output, 'stack:', error) return render_template('code.html', code=code, input=input, output=output, stack=error or '[]') else: return render_template('primary.html')
def get_non_contributors_users_jobs(queue='quaterly'): """Return a list of users that have never contributed to a project.""" from sqlalchemy.sql import text from pybossa.model.user import User from pybossa.core import db # Second users that have created an account but never participated sql = text('''SELECT id FROM "user" WHERE NOT EXISTS (SELECT user_id FROM task_run WHERE task_run.user_id="user".id)''') results = db.slave_session.execute(sql) timeout = current_app.config.get('TIMEOUT') for row in results: user = User.query.get(row.id) if user.subscribed: subject = "Why don't you help us?!" body = render_template('/account/email/noncontributors.md', user=user.dictize(), config=current_app.config) html = render_template('/account/email/noncontributors.html', user=user.dictize(), config=current_app.config) mail_dict = dict(recipients=[user.email_addr], subject=subject, body=body, html=html) job = dict(name=send_mail, args=[mail_dict], kwargs={}, timeout=timeout, queue=queue) yield job
def stuffster(): """Start page, redirects to login if there is no cookie for the user""" if 'username' in session: cats = db.get_categories(session['username']) note = db.get_note(session['username']) return render_template('template.html', categories = cats, user_note = note) return render_template('login.html')
def edit_comment(comment_id): if request.method == 'POST': if request.form['action'] == 'delete': with dbapi2.connect(flask.current_app.config['dsn']) as connection: cursor = connection.cursor() query = """DELETE FROM POST WHERE (POSTID= %s)""" cursor.execute(query, [comment_id]) connection.commit() return redirect(url_for('site.main_page')) else: return render_template('edit_comment.html') else: with dbapi2.connect(flask.current_app.config['dsn']) as connection: cursor = connection.cursor() query = """SELECT * FROM POST WHERE POSTID = %s""" cursor.execute(query, [comment_id]) post = cursor.fetchall() connection.commit() return render_template('edit_comment.html', post = post)
def docheck(): # session[] 存資料 # session.get() 取 session 資料 # 利用 request.form[] 取得表單欄位資料, 然後送到 template guess = request.form["guess"] session["guess"] = guess # 假如使用者直接執行 doCheck, 則設法轉回根方法 if guess is None: redirect("/") # 從 session 取出 answer 對應資料, 且處理直接執行 docheck 時無法取 session 值情況 try: theanswer = int(session.get('answer')) except: redirect("/") # 經由表單所取得的 guess 資料型別為 string try: theguess = int(guess) except: return redirect("/guessform") # 每執行 doCheck 一次,次數增量一次 session["count"] += 1 count = session.get("count") # 答案與所猜數字進行比對 if theanswer < theguess: return render_template("toobig.html", guess=guess, answer=theanswer, count=count) elif theanswer > theguess: return render_template("toosmall.html", guess=guess, answer=theanswer, count=count) else: # 已經猜對, 從 session 取出累計猜測次數 thecount = session.get('count') return "猜了 "+str(thecount)+" 次, 終於猜對了, 正確答案為 "+str(theanswer)+": <a href='/'>再猜</a>" return render_template("docheck.html", guess=guess)
def m_nurse_update(): action_type = request.values.get("action_type", None) if not action_type: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_nurse_list")) if action_type == "n": cs = connection.Clinic.find({'active':0}).sort('name') return render_template("m_nurse_new.html", clinics = cs) elif action_type in ["m", "d"]: id = request.values.get("id", None) if not id: flash("No nurse id supply", MESSAGE_ERROR) return redirect(url_for("m_nurse_list")) n = connection.NurseProfile.one({'id' : int(id)}) if action_type == "m": cs = connection.Clinic.find({'active':0}).sort('name') return render_template("m_nurse_update.html", nurse = n, clinics = cs) elif action_type == "d": n.active = 1 n.save() l = connection.SystemLog() l.uid = session['user_profile']['id'] l.type = u'DELETE NURSE' l.content = u'%s delete the nurse [name : %s, id : %d]' % (session['user_profile']['name'], n.name, n.id) flash("The nurse [%s] has been deleted successfully !" % n.name, MESSAGE_INFO) return redirect(url_for("m_nurse_list")) else: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_nurse_list"))
def m_clinic_update(): action_type = request.values.get("action_type", None) if not action_type: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_clinic_list")) if action_type == "n": return render_template("m_clinic_new.html") elif action_type in ["m", "d"]: id = request.values.get("id", None) if not id: flash("No clinic id supply", MESSAGE_ERROR) return redirect(url_for("m_clinic_list")) c = connection.Clinic.one({'id' : int(id)}) if action_type == "m": return render_template("m_clinic_update.html", clinic = c) elif action_type == "d": c.active = 1 c.save() l = connection.SystemLog() l.uid = session['user_profile']['id'] l.type = u'DELETE CLINIC' l.content = u'%s delete the clinic [name : %s, id : %d]' % (session['user_profile']['name'], c.name, c.id) flash("The clinic [%s] has been deleted successfully !" % c.name, MESSAGE_INFO) return redirect(url_for("m_clinic_list")) else: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_clinic_list"))
def update_account(): form = AccountDataForm() user = g.user if request.method == 'GET': form.email.data = user.email form.language.data = user.language form.timezone.data = user.timezone elif request.method == 'POST' and form.validate_on_submit(): if password_hash(form.old_password.data) != user.password: form.old_password.errors.append(_('Wrong password')) return render_template('update_account.html', form=form) if form.email.data != user.email: user.email = form.email.data user.confirmed = False user.confirmation_string = random_string(20) msg = message_confirmation(user.id, user.email, user.confirmation_string) mail.send(msg) flash(_('Confirmation message sent, check your e-mail')) if form.password.data: user.password = password_hash(form.password.data) flash(_('Password successfully changed')) user.language = form.language.data user.timezone = form.timezone.data db.session.commit() return redirect('update_account') return render_template('update_account.html', form=form)
def m_doctor_update(): action_type = request.values.get("action_type", None) if not action_type: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_doctor_list")) if action_type == "n": cs = connection.Clinic.find({'active':0}).sort('name') cats = connection.Category.find({'active':0}).sort('name') return render_template("m_doctor_new.html", clinics = cs, categories = cats) elif action_type in ["m", "d"]: id = request.values.get("id", None) if not id: flash("No doctor id supply", MESSAGE_ERROR) return redirect(url_for("m_doctor_list")) d = connection.DoctorProfile.one({'id' : int(id)}) if action_type == "m": cs = connection.Clinic.find({'active':0}).sort('name') cats = connection.Category.find({'active':0}).sort('name') return render_template("m_doctor_update.html", doctor = d, clinics = cs, categories = cats) elif action_type == "d": info = d.populate() d.active = 1 d.save() l = connection.SystemLog() l.uid = session['user_profile']['id'] l.type = u'DELETE DOCTOR' l.content = u'%s delete the doctor profile [name : %s, id : %d]' % (session['user_profile']['name'], info['name'], d.id) flash("The doctor profile [%s] has been deleted successfully !" % info['name'], MESSAGE_INFO) return redirect(url_for("m_doctor_list")) else: flash("No such action type !", MESSAGE_ERROR) return redirect(url_for("m_clinic_list"))
def search_text(): if request.method == 'POST': search_term = request.form['search_term'] results = Document.query.search(search_term) return render_template('search_results.html', results=results, search_term=search_term) else: return render_template('search.html')
def run(): form = GoalTimeForm(request.form) if request.method == "POST" and form.validate_on_submit(): plan = generate_plan( form.wave.data, form.hours.data, form.minutes.data, ) start_time = plan[0].strftime("%I:%M %p") goal_pace = "%d:%d" % (plan[1] / 60, plan[1] % 60) goal_finish = plan[2].strftime("%I:%M %p") beer_time = plan[3].strftime("%I:%M %p") plan_points = plan[4] friend_link = plan[5] return render_template( "layout.html", form=form, viewing_points=plan_points, start_time=start_time, goal_pace=goal_pace, goal_finish=goal_finish, beer_time=beer_time, friend_link=friend_link, ) else: if request.args.get("wave"): form.wave.data = request.args.get("wave") form.hours.data = request.args.get("hours") form.minutes.data = request.args.get("minutes") return render_template("layout.html", form=form)
def edit_listing(listing_id): listing = session.query(Listing).get(listing_id) if listing is None: return abort(404) if not g.user.is_authenticated(): return render_template('listing.html', listing_id=listing_id, title=listing.title, description=listing.description, price=listing.price, image=listing.image, message='You must be logged in to edit your listing.') if g.user.id != listing.user_id: return render_template('listing.html', email=g.user.email, listing_id=listing_id, title=listing.title, description=listing.description, price=listing.price, image=listing.image, message='Only the creator of this listing may edit it.') if request.method == 'GET': return render_template('edit_listing.html', listing_id=listing_id, title=listing.title, description=listing.description, price=listing.price, image=listing.image) elif request.method == 'POST': title = request.form['title'] description = request.form['description'] category = request.form['category'] price = request.form['price'] image = None if 'image' in request.files: image_file = request.files['image'].read() if image_file != '': image = buffer(image_file) listing.image = image if title != '': listing.title = title if description != '': listing.description = description if category != '': category_id = session.query(Category).filter(Category.name == category).first() listing.category_id = category_id if price != '' and is_number(price): listing.price = price session.commit() return redirect(url_for('listing', listing_id=listing_id))
def login(): # If a user is already logged in. is_authenticated is a function # of the User class in models.py if g.user.is_authenticated(): return render_template('index.html', message='A user is already logged in.', email=g.user.email, listings=get_listings()) # If the user is sending information (i.e. trying to log in), # checks the selected email against the users in the database. if request.method == 'POST': email = request.form['email'] password = request.form['password'] # queries the database for a user with the email submitted user = session.query(User).filter(User.email == email).first() # if the user was in the database and the password matches, # logs the user in and returns a message. if user is not None and pwd_context.verify(password, user.password): login_user(user) return render_template('index.html', message='Login was successful.', email=user.email, listings=get_listings()) return render_template('index.html', message='Email or password invalid. Please try again.', listings=get_listings()) # returns login form if request method was GET return render_template('login.html')
def tickets(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Tickets') return render_template('index.html', active='Tickets')
def other(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Miscellaneous') return render_template('index.html', active='Miscellaneous')
def electronics(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Electronics') return render_template('index.html', active='Electronics')
def mmg(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Movies, Music, and Games') return render_template('index.html', active='Movies, Music, and Games')
def a_a(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Apparel/Accessories') return render_template('index.html', active='Apparel/Accessories')
def appliances(): if g.user.is_authenticated(): return render_template('index.html', username=g.user.email, active='Appliances') return render_template('index.html', active='Appliances')
def totp_user_view(): if not totp_user_enabled(session['username']): if request.method == 'GET': return render_template('totp_enable.html',active="user") elif request.method == 'POST': ## verify the token entered token = request.form['totp_token'] if totp_verify_token(session['username'],token): flash("Two step logon has been enabled for your account","alert-success") g.redis.set('totp.%s.enabled' % session['username'],"True") else: flash("Invalid code! Two step logons could not be enabled","alert-danger") return redirect(url_for('totp_user_view')) else: if request.method == 'GET': return render_template('totp_disable.html',active="user") elif request.method == 'POST': ## verify the token entered token = request.form['totp_token'] if totp_verify_token(session['username'],token): g.redis.delete('totp.%s.enabled' % session['username']) g.redis.delete('totp.%s.key' % session['username']) flash("Two step logons have been disabled for your account","alert-warning") else: flash("Invalid code! Two step logons were not disabled","alert-danger") return redirect(url_for('totp_user_view'))
def search(): form = SearchForm() if form.validate_on_submit(): results = wiki.search(form.term.data, form.ignore_case.data) return render_template('search.html', form=form, results=results, search=form.term.data) return render_template('search.html', form=form, search=None)
def upload_pdn(): if request.method == 'POST': error = None f = request.files['file'] if not f: error = 'Geen bestand geselecteerd' elif not allowed_file(f.filename): error = 'Bestand niet geaccepteerd' else: filename = secure_filename(f.filename) #f.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) collection_name = request.form['name'].lower() if not collection_name: error = 'Geen naam opgegegeven' else: c = Collection.query.filter_by(name=collection_name).first() if c: error = 'Naam is al in gebruik: verzin een andere naam!' else: upload_file(f, collection_name) return redirect(url_for('collection', collection_name=collection_name)) return render_template('upload.html', error=error) else: return render_template('upload.html')
def login(): if request.method == 'GET': return render_template('login.html') facebook_id = request.form.get('facebook_id') facebook_token = request.form.get('facebook_token') if not facebook_id or not facebook_token: flash(u"잘못된 로그인 정보입니다.") return render_template('login.html'), 400 me = facebook_auth(facebook_token) if not me: flash(u"페이스북 인증에 실패했습니다.") return render_template('login.html'), 400 if me['id'] not in current_app.config['ALLOWED_FACEBOOK_USERS']: flash(u"허용되지 않은 사용자입니다.") return render_template('login.html'), 400 user = User.query.filter_by(facebook_id=str(me['id'])).first() if user is None: user = User() user.name = me['name'] user.facebook_id = facebook_id user.facebook_token = facebook_token db.session.add(user) db.session.commit() login_user(user) return redirect(url_for('web.item_list'))
def user_home(): dic_codes = dict([(code.id,code.code_name) for code in Dic_code.query.all()]) data_type = request.args.get('name') if data_type == 'index': user_data = Tab.query.outerjoin(Like, Tab.id==Like.like_id).filter(Like.uid==current_user.id)\ .filter(Like.like_type==1) elif data_type == 'tabs': user_data = Tab.query.filter_by(uid=current_user.id).order_by(Tab.create_time.desc()) elif data_type == 'artists': user_data = Artist.query.outerjoin(Like, Artist.id==Like.like_id).filter(Like.uid==current_user.id)\ .filter(Like.like_type==2) else: user_data = Question.query.filter_by(uid=current_user.id).order_by(Question.create_time.desc()) page = request.args.get('page') if page and int(page) >= 1: page = int(page) user_data = user_data.paginate(page, 40, False) return render_template('users/likes_filter_ajax.html', user_data=user_data, dic_codes=dic_codes, data_type=data_type) else: page = 1 user_data = user_data.paginate(page, 40, False) return render_template('users/user_home.html', user_data=user_data, dic_codes=dic_codes, data_type=data_type)
def track_book_location(): if request.method == 'GET': return render_template('track-book-location.html') elif request.method == 'POST': f = request.form location_info = database.track_book(f['isbn']) return render_template('track-book-location.html', location_info = location_info)
def login(): '''Login to Matterhorn. This method will request the Matterhorn Login page to obtain a session which can be used for further requests. ''' error = None if request.method == 'POST': # Prepare data data = { 'j_username': request.form['username'], 'j_password': request.form['password'] } try: opener = urllib2.build_opener(NoRedirection) u = opener.open(app.config['SECURITY_SERVICE'], urllib.urlencode(data)) if u.headers.get('location'): if '/login.html' in u.headers.get('location'): return render_template('login.html', error='Could not log in. Incorrect credentials?') cookie = u.headers.get('Set-Cookie') u.close() response = redirect(url_for('home')) response.headers['Set-Cookie'] = cookie return response except urllib2.HTTPError as e: if e.code == 404: return render_template('login.html', error='Login service returned error. Please report this.') if e.code == 401: return render_template('login.html', error='Could not log in. Incorrect credentials?') raise e return render_template('login.html')
def warn_old_project_owners(): """E-mail the project owners not updated in the last 3 months.""" from pybossa.core import mail, project_repo from pybossa.cache.projects import clean from flask.ext.mail import Message projects = get_non_updated_projects() with mail.connect() as conn: for project in projects: subject = ('Your %s project: %s has been inactive' % (current_app.config.get('BRAND'), project.name)) body = render_template('/account/email/inactive_project.md', project=project) html = render_template('/account/email/inactive_project.html', project=project) msg = Message(recipients=[project.owner.email_addr], subject=subject, body=body, html=html) conn.send(msg) project.contacted = True project.published = False clean(project.id) project_repo.update(project) return True
def register(): # if a user is already logged in if g.user.is_authenticated(): return render_template('index.html', message='Please logout before attempting to create a new_account.', email=g.user.email, listings=get_listings()) if request.method == 'POST': email = request.form['email'] password = request.form['password'] user = session.query(User).filter(User.email == email).first() if user is not None: return render_template('index.html', message='An account with that email already exists. If you have forgotten your password,' + ' go to "buy5c.com/forgot_password" to find out how to reset it.', listings=get_listings()) # if no user with that email exists, creates one and adds it to the database else: password = pwd_context.encrypt(password) user = User(email, password) session.add(user) session.commit() return render_template('index.html', message='Account successfully created.', listings=get_listings()) return render_template('register.html')
def create_artist_form(): form = ArtistForm() return render_template('forms/new_artist.html', form=form)
def show_main(username): #检察权限 ckr = check_login(request.cookies.get('token')) if ckr == False: return redirect('/') #获取页面参数 p = request.args.get('page') if p == None: p = 'panel' linfo = Main_dbc.get_one('pages', {'url': p}) pinfo = Main_dbc.get_one('info', {'page': 'main'}) if linfo == None: page = { 'username': ckr['username'], 'description': '', 'title': pinfo['title'] + ' - ' + '404', 'favicon': Main_cfg['favicon'], 'appicon': Main_cfg['appicon'], 'now': '404' } return render_template('main.html', page=page) page = { 'username': ckr['username'], 'description': linfo['description'], 'title': pinfo['title'] + ' - ' + linfo['name'], 'favicon': Main_cfg['favicon'], 'appicon': Main_cfg['appicon'], 'now': p, 'menus': [], 'plugin': {}, 'select': p } #获取普通页面数据 (a, b) = page_getinfo(p) page[a] = b[a] #处理菜单生产 验证 auth = False for group in ckr['group']: pages = Main_dbc.get_all('pages', {'group': group}) for i in pages: if i['show'] == 1: page['menus'].append(i) if i['url'] == p: auth = True if auth == False: page['now'] = 'auth' return render_template('main.html', page=page) #判断是否加载插件 if linfo['father'] != "": args = { 'requests': request.args, 'user': ckr, 'cookies': request.cookies } (page_plugin, now) = Main_plugins.exec(linfo['father'], 'build_page', args) page['plugin'] = page_plugin page['now'] = now Main_logger.info(now) Main_logger.info(page) try: return render_template('main.html', page=page) except: page['now'] = '404' return render_template('main.html', page=page)
def tasks(): return render_template("tasks.html")
def index(): return render_template("index.html", date = datetime.now())
def server_error(error): return render_template('errors/500.html'), 500
def not_found_error(error): return render_template('errors/404.html'), 404
def shows(): # displays list of shows at /shows # TODO: replace with real venues data. # num_shows should be aggregated based on number of upcoming shows per venue. shows = Show.query.all() print(len(shows), "Anzahl Shows:") data = [] for show in shows: print('nextShow:{}'.format(show)) data.append({ "venue_id": show.venue_id, "venue_name": show.venue.name, "artist_id": show.artist_id, "artist_name": show.artist.name, "artist_image_link": show.artist.image_link, "start_time": show.start_time.strftime("%Y-%m-%dT%H:%M:%S.000Z") }) print(data) # data=[{ # "venue_id": 1, # "venue_name": "The Musical Hop", # "artist_id": 4, # "artist_name": "Guns N Petals", # "artist_image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", # "start_time": "2019-05-21T21:30:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "artist_id": 5, # "artist_name": "Matt Quevedo", # "artist_image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", # "start_time": "2019-06-15T23:00:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-01T20:00:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-08T20:00:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-15T20:00:00.000Z" # }] return render_template('pages/shows.html', shows=data)
def create_venue_form(): form = VenueForm() return render_template('forms/new_venue.html', form=form)
def index(): return render_template('pages/home.html')
def show_artist(artist_id): # shows the venue page with the given venue_id # TODO: replace with real venue data from the venues table, using venue_id artist = Artist.query.get(artist_id) upcoming_shows = list( filter(lambda s: s.start_time > datetime.today(), artist.shows)) past_shows = list( filter(lambda s: s.start_time <= datetime.today(), artist.shows)) print(artist) if artist is None: flash('Artist with ID {} not found'.format(artist_id)) redirect(url_for('index')) else: data = { "id": artist.id, "name": artist.name, "genres": artist.genres.split(','), "city": artist.city, "state": artist.state, "phone": artist.phone, "website": artist.website, "facebook_link": artist.facebook_link, "seeking_venue": artist.seeking_venue, "seeking_description": artist.seeking_description, "image_link": artist.image_link, "past_shows": [{ "venue_id": s.venue_id, "venue_name": s.venue.name, "venue_image_link": s.venue.image_link, "start_time": s.start_time.strftime("%Y-%m-%dT%H:%M:%S.000Z") } for s in past_shows], "upcoming_shows": [{ "venue_id": s.venue_id, "venue_name": s.venue.name, "venue_image_link": s.venue.image_link, "start_time": s.start_time.strftime("%Y-%m-%dT%H:%M:%S.000Z") } for s in upcoming_shows], "past_shows_count": len(past_shows), "upcoming_shows_count": len(upcoming_shows), } # data1={ # "id": 4, # "name": "Guns N Petals", # "genres": ["Rock n Roll"], # "city": "San Francisco", # "state": "CA", # "phone": "326-123-5000", # "website": "https://www.gunsnpetalsband.com", # "facebook_link": "https://www.facebook.com/GunsNPetals", # "seeking_venue": True, # "seeking_description": "Looking for shows to perform at in the San Francisco Bay Area!", # "image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", # "past_shows": [{ # "venue_id": 1, # "venue_name": "The Musical Hop", # "venue_image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", # "start_time": "2019-05-21T21:30:00.000Z" # }], # "upcoming_shows": [], # "past_shows_count": 1, # "upcoming_shows_count": 0, # } # data2={ # "id": 5, # "name": "Matt Quevedo", # "genres": ["Jazz"], # "city": "New York", # "state": "NY", # "phone": "300-400-5000", # "facebook_link": "https://www.facebook.com/mattquevedo923251523", # "seeking_venue": False, # "image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", # "past_shows": [{ # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", # "start_time": "2019-06-15T23:00:00.000Z" # }], # "upcoming_shows": [], # "past_shows_count": 1, # "upcoming_shows_count": 0, # } # data3={ # "id": 6, # "name": "The Wild Sax Band", # "genres": ["Jazz", "Classical"], # "city": "San Francisco", # "state": "CA", # "phone": "432-325-5432", # "seeking_venue": False, # "image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "past_shows": [], # "upcoming_shows": [{ # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", # "start_time": "2035-04-01T20:00:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", # "start_time": "2035-04-08T20:00:00.000Z" # }, { # "venue_id": 3, # "venue_name": "Park Square Live Music & Coffee", # "venue_image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", # "start_time": "2035-04-15T20:00:00.000Z" # }], # "past_shows_count": 0, # "upcoming_shows_count": 3, # } # data = list(filter(lambda d: d['id'] == artist_id, [data1, data2, data3]))[0] return render_template('pages/show_artist.html', artist=data)
def index(): return render_template('index.html')
def show_venue(venue_id): # shows the venue page with the given venue_id # TODO: replace with real venue data from the venues table, using venue_id venue = Venue.query.get(venue_id) if venue is None: flash('Venue with ID {} not found!'.format(venue_id)) return redirect(url_for('index')) else: upcoming_shows = list( filter(lambda s: s.start_time > datetime.today(), venue.shows)) past_shows = list( filter(lambda s: s.start_time <= datetime.today(), venue.shows)) data = { "id": venue.id, "name": venue.name, "genres": venue.genres.split(','), "city": venue.city, "phone": venue.phone, "address": venue.address, "website": venue.website, "facebook_link": venue.facebook_link, "seeking_talent": venue.seeking_talent, "seeking_description": venue.seeking_description, "image_link": venue.image_link, "past_shows": [{ "artist_id": s.artist_id, "artist_name": s.artist.name, "artist_image_link": s.artist.image_link, "start_time": s.start_time.strftime("%Y-%m-%dT%H:%M:%S.000Z") } for s in past_shows], "upcoming_shows": [{ "artist_id": s.artist_id, "artist_name": s.artist.name, "artist_image_link": s.artist.image_link, "start_time": s.start_time.strftime("%Y-%m-%dT%H:%M:%S.000Z") } for s in upcoming_shows], "past_shows_count": len(past_shows), "upcoming_shows_count": len(upcoming_shows), } # data1={ # "id": 1, # "name": "The Musical Hop", # "genres": ["Jazz", "Reggae", "Swing", "Classical", "Folk"], # "address": "1015 Folsom Street", # "city": "San Francisco", # "state": "CA", # "phone": "123-123-1234", # "website": "https://www.themusicalhop.com", # "facebook_link": "https://www.facebook.com/TheMusicalHop", # "seeking_talent": True, # "seeking_description": "We are on the lookout for a local artist to play every two weeks. Please call us.", # "image_link": "https://images.unsplash.com/photo-1543900694-133f37abaaa5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", # "past_shows": [{ # "artist_id": 4, # "artist_name": "Guns N Petals", # "artist_image_link": "https://images.unsplash.com/photo-1549213783-8284d0336c4f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=300&q=80", # "start_time": "2019-05-21T21:30:00.000Z" # }], # "upcoming_shows": [], # "past_shows_count": 1, # "upcoming_shows_count": 0, # } # data2={ # "id": 2, # "name": "The Dueling Pianos Bar", # "genres": ["Classical", "R&B", "Hip-Hop"], # "address": "335 Delancey Street", # "city": "New York", # "state": "NY", # "phone": "914-003-1132", # "website": "https://www.theduelingpianos.com", # "facebook_link": "https://www.facebook.com/theduelingpianos", # "seeking_talent": False, # "image_link": "https://images.unsplash.com/photo-1497032205916-ac775f0649ae?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80", # "past_shows": [], # "upcoming_shows": [], # "past_shows_count": 0, # "upcoming_shows_count": 0, # } # data3={ # "id": 3, # "name": "Park Square Live Music & Coffee", # "genres": ["Rock n Roll", "Jazz", "Classical", "Folk"], # "address": "34 Whiskey Moore Ave", # "city": "San Francisco", # "state": "CA", # "phone": "415-000-1234", # "website": "https://www.parksquarelivemusicandcoffee.com", # "facebook_link": "https://www.facebook.com/ParkSquareLiveMusicAndCoffee", # "seeking_talent": False, # "image_link": "https://images.unsplash.com/photo-1485686531765-ba63b07845a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=747&q=80", # "past_shows": [{ # "artist_id": 5, # "artist_name": "Matt Quevedo", # "artist_image_link": "https://images.unsplash.com/photo-1495223153807-b916f75de8c5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80", # "start_time": "2019-06-15T23:00:00.000Z" # }], # "upcoming_shows": [{ # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-01T20:00:00.000Z" # }, { # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-08T20:00:00.000Z" # }, { # "artist_id": 6, # "artist_name": "The Wild Sax Band", # "artist_image_link": "https://images.unsplash.com/photo-1558369981-f9ca78462e61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=794&q=80", # "start_time": "2035-04-15T20:00:00.000Z" # }], # "past_shows_count": 1, # "upcoming_shows_count": 1, # } # data = list(filter(lambda d: d['id'] == venue_id, [data1, data2, data3]))[0] return render_template('pages/show_venue.html', venue=data)
def client(): return render_template('client.html')
def home(): return render_template('index.html')
def index(): return render_template('index.html', schools=schools)
def show_me(): return render_template('user/show.html', user=current_user)
def get_food(): return render_template('food.html',data=get_all())
def show_school(school_code): school = schools_by_key.get(school_code) if school: return render_template('map.html', school=school) else: abort(404)
def crypto(): return render_template("crypto.html")
def render_static(): return render_template('tag.html')
def success(): if request.method == 'POST': email = request.form['email'] return render_template('success.html', email=email) else: pass
def edit_food(name): food = get_food_by_name(name) return render_template('food_edit.html',food=food)
def home(): return render_template("index.html")
def employee(): if request.method == 'GET': result = {'employee_id': 1, 'employee_name': "Kadar Khan"} return render_template('employee_details', emp_details=result)
def contact(): return render_template("contact.html")
def login(): return render_template('login.html')
def game_review(user, game_num): API.login(LOGIN, PASSWORD, "ru_RU") REVIEWER.init_match(*API.get_game_params(user, int(game_num))) return render_template('match_review.html', iterations_num=REVIEWER.iterations_num - 1)
def single(): return render_template("single.html")
def leaderboard(): return render_template('table.html', users=API.parse_top_100())
def about(): return render_template("about.html")