def findStudent(): form = inputForm() conn = sqlite3.connect('week10.db') c = conn.cursor() query = 'select id, student from lab10 where Student is not null order by student' c.execute(query) theseStudents = list(c.fetchall()) nameList = theseStudents form.lstNames.choices = nameList if request.method == 'POST': Name = form.lstNames.data c1 = conn.cursor() query = 'select id, link from lab10 where id={}'.format(int(Name)) c1.execute(query) oneRecord = c1.fetchone() thisUrl = base64.urlsafe_b64decode(oneRecord[1]).decode('utf-8') # If new is 0, the url is opened in the same browser window if possible. # If new is 1, a new browser window is opened if possible. # If new is 2, a new browser page (“tab”) is opened if possible. webbrowser.open(thisUrl, new=1) c1.close() c.close() return render_template('inputForm.html', form=form, the_title='Find student')
def home(): music = os.listdir('mp3_files/') if music: if music[0] == 'ilteris.mp3': os.remove('mp3_files/ilteris.mp3') form = inputForm(request.form) return render_template('index.html', form=form)
def create(): form = inputForm(request.form) if request.method == 'POST' and form.validate(): address = request.form.get('address') url = pyqrcode.create(address) url.png('static/url.png', scale=8) return render_template('index.html', form=form, address=address) return render_template('index.html', form=form, address=address)
def main_page(): form = inputForm() if request.method == 'POST': if form.validate() == False: flash('All fields are required.') return render_template('index.html', form = form) else: return render_template('success.html') elif request.method == 'GET': return render_template('index.html', form = form)
def start(): music = os.listdir('mp3_files/') if music: if music[0] == 'ilteris.mp3': os.remove('mp3_files/ilteris.mp3') form = inputForm(request.form) if request.method == 'POST' and form.validate(): music = os.listdir('mp3_files/') if music: if music[0] == 'ilteris.mp3': os.remove('mp3_files/ilteris.mp3') dwnldr = downloader.Downloader(app.config['DOWNLOAD_FOLDER']) youtube_url = request.form.get('youtube_url') dwnldr.startDownloading(youtube_url) file_name = os.listdir('mp3_files/') file_name = str(file_name[0]) return send_file('mp3_files/' + file_name, as_attachment=True) return render_template('index.html', form=form)
def find_student(): form = inputForm() con = sqlite3.connect('week10.db') c = con.cursor() query = "select id, student from lab10 where student is not null order by student" c.execute(query) theseStudents = list(c.fetchall()) nameList = theseStudents form.lstNames.choices = nameList if request.method == "POST": Name = form.lstNames.data c1 = con.cursor() query = "select id, link from lab10 where id={}".format(int(Name)) c1.execute(query) oneRecord = c1.fetchone() thisUrl = base64.urlsafe_b64decode(oneRecord[1]).decode("utf-8") webbrowser.open(thisUrl, new=2) c1.close() c.close() return render_template("inputForm.html", form=form, the_title="Find the student")
def home(): form = inputForm(request.form) return render_template('index.html', form=form)
def add_input(self): form = forms.inputForm() module = ip.CvtColor name = 'input' self.insert_items(form, module, name) return (form, module)