def profile(): form = MyForm() print form.validate_on_submit() print form.errors print request.form if request.method == 'POST' and form.validate_on_submit(): count = db.session.query(UserProfile).count() location = form.location.data bio = form.biography.data lname = form.lastname.data fname = form.firstname.data mail = form.email.data gender = form.gender.data photograph = form.photo.data date = datetime.date.today() uid = 10000 + count filename = str(uid) + ".jpg" photograph.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) user = UserProfile(id=uid, first_name=fname, last_name=lname, gender=gender, location=location, bio=bio, email=mail, created_on=date) db.session.add(user) db.session.commit() flash('Profile created!', 'success') return redirect(url_for('profiles')) else: return render_template('profile.html', form=form)
def put_applicant(): global job_id if request.method == 'POST': if request.get_json(): job_data = request.get_json() job_id = job_data['id'] return jsonify({"message": "success"}) form = MyForm() form.validate_on_submit() for key, value in form.errors.items(): flash(value, 'error') # if action is POST and form is valid if form.validate_on_submit(): result = request.form.to_dict() data = { 'firstname': result['firstname'], 'surname': result['surname'], 'email': result['email'], 'dob': result['dob'], 'phone': result['phone'], 'job_ref': job_id[3:] } if client: # for reading the job_ref job_data = request.get_json() flag = False # check whether in the database there is no user with these credentials # an user CANNOT apply for the same job once but CAN apply two different jobs for document in appi_db: if (document['email'] == data['email']) and (job_id[3:] == document['job_ref']): flag = True if flag == False: # create a document and add the data to it my_document = appi_db.create_document(data) flash('You have been added to the database', 'success') # use sessions to share the document info to the other routes session['document'] = my_document else: flash('Sorry you cannot apply for the same job twice', 'validation') return render_template('applicant.html', form=form) else: print('No database') return jsonify(data) return render_template('applicant.html', form=form)
def profile(): myform = MyForm() if request.method == 'POST': if myform.validate_on_submit(): firstname = myform.firstname.data lastname = myform.lastname.data email = myform.email.data location = myform.location.data biography = myform.biography.data gender = myform.gender.data photo = myform.photo.data filename = secure_filename(photo.filename) photo.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) userid = str(uuid.uuid4()) created_on = format_date_joined() db = connect_db() cur = db.cursor() query = "insert into Profiles (firstname, lastname, email, location, biography, gender, photo, userid, created_on) values (%s, %s, %s, %s, %s, %s, %s, %s, %s);" data = (firstname, lastname, email, location, biography, gender, filename, userid, created_on) cur.execute(query, data) db.commit() flash('Profile successfully added!', 'success') return redirect(url_for("profiles")) flash_errors(myform) return render_template('profile.html', form=myform)
def login(): tkn = '' try: AXS_TOKEN = session.get('oauth_token') AXS_TOKEN_SECRET = session.get('oauth_token_secret') VERIF = request.args.get('oauth_verifier', '') tkn = CLIENT.get_access_token(AXS_TOKEN, AXS_TOKEN_SECRET, VERIF) # this is the tkn we need to save! session['tkn'] = tkn except (KeyError, ValueError): pass if not tkn: tkn = session.get('tkn') try: note_store = CLIENT.get_note_store() except TypeError: global CLIENT CLIENT = get_evernote_client(tkn) form = MyForm() if form.validate_on_submit(): new = User(form.data['email'], session.get('tkn')) db.session.add(new) db.session.commit() # need to stop people from adding the same username return redirect(url_for('.success')) return render_template('authorized.html', form=form)
def contact(): form = MyForm() if form.validate_on_submit(): return "Hey there, {}!".format(form.name.data) else: return render_template("contact.html", form=form)
def register(): form = MyForm() if form.validate_on_submit(): # cur = mysql.connection.cursor() # cur.execute("INSERT INTO kaskoghar(username,email,password,name) VALUES(%s,%s,%s,%s)",(form.username.data,form.email.data,form.password.data,form.name.data)) # mysql.connection.commit() # cur.close() db.session.close() x = db.session.query(KaskoGhar).filter_by( username=form.username.data).first() if (x): flash('choose a different username ') return render_template('registration.html', form=form) formdata = KaskoGhar(username=form.username.data, email=form.email.data, password=generate_password_hash( form.password.data), name=form.name.data) print(type(formdata)) db.session.add(formdata) db.session.commit() print(db.session) return redirect(url_for('home')) return render_template('registration.html', form=form)
def submit(): form = MyForm() if form.validate_on_submit(): name = form.name.data print name store_bookmark(name, name) return 'success data' return render_template('submit.html', form=form)
def home(): form = MyForm() if form.validate_on_submit(): date = form.date.data city = form.city.data return render_template("login.html", title='Prometric check', form=form)
def contact(): myform=MyForm() """Render the website's contact page.""" if request.method == 'POST' and myform.validate_on_submit(): send_mail(myform.name.data,myform.email.data,myform.subject.data,myform.message.data) flash('Message Successfully Sent') return redirect(url_for('home')) else: return render_template('contact.html',form=myform,addtext='Error sending')
def signup(): if current_user.is_authenticated: return redirect(url_for('dashboard')) form = MyForm() if request.method == "POST" and form.validate_on_submit(): # referral = request.form.get('ref') email = form.email.data password = form.password.data username = form.username.data bank_name = form.bank_name.data account_name = form.account_name.data account_number = form.account_number.data bitcoin_wallet = form.bitcoin_wallet.data mobile_number = form.mobile_number.data country = request.form.get("country") referral = form.referral.data password = md5_crypt.hash(password) check_for_first_user = len(User.query.all()) if not check_for_first_user: user = User(username=username, referral=referral, is_admin=True, password=password, country=country, account_number=account_number, account_name=account_name, bitcoin_addr=bitcoin_wallet, bank_name=bank_name, mobile_number=mobile_number, email=email) else: user = User(username=username, referral=referral, is_admin=False, password=password, country=country, account_number=account_number, account_name=account_name, bitcoin_addr=bitcoin_wallet, bank_name=bank_name, mobile_number=mobile_number, email=email) db.session.add(user) db.session.commit() flash("You have signed up successfully") return redirect('/login') else: ref = request.args.get("ref") context = {"ref": ref} all_tasks = Admin_tasks.query.all() for task in all_tasks: context[f"{task.key}"] = task.value return render_template("sign_up.html", form=form, context=context)
def contact(): form = MyForm() if form.validate_on_submit(): msg = Message(request.form['subject'], sender=(request.form['name'], request.form['email']), recipients=["*****@*****.**"]) msg.body = request.form['message'] mail.send(msg) msg.body = request'This is the body of the message' return redirect(url_for('home')) return render_template('contact.html', form=form)
def index(): form = MyForm() # post if form.validate_on_submit(): # extract form input data input_value = form.name.data result = input_value.upper() return render_template('result.html', result=result) # get return render_template('index.html', form=form)
def contact(): form = MyForm() if form.validate_on_submit(): msg = Messagere) msg.body = request.form['message'] mail.send(msg) return redirect(url_for('home')) return render_template('contact.html', form=form)
def contact(): form = MyForm() if request.method == 'POST': print form.validate_on_submit() if form.validate_on_submit(): name = form.name.data email = form.email.data subject = form.subject.data message = form.messages.data msg = Message(subject, sender=(name, email), recipients=["*****@*****.**"]) msg.body = message mail.send(msg) flash('Message sent successfuly') return redirect(url_for('home')) return render_template('contact.html', form=form)
def contact(): form = MyForm() if request.method == "POST": if form.validate_on_submit(): msg = Message("subject", sender=("name", "email"), recipients=["*****@*****.**"]) msg.body = 'message' mail.send(msg) flash('message has been sent!!', 'success') return redirect(url_for('home')) return render_template('contact.html', form=form)
def contact(): form = MyForm() if request.method == 'POST': print form.validate_on_submit() if form.validate_on_submit(): subject = form.subject.data message = form.messages.data name = form.Name.data email = form.mail.data msg = Message(subject, sender=(name, email), recipients=["*****@*****.**"]) msg.body = message mail.send(msg) flash('Sucesfully sent message.') return redirect(url_for('home')) else: return render_template('contact.html', form=form) else: return render_template('contact.html', form=form)
def contact(): form = MyForm() if form.validate_on_submit(): msg = Message(request.form['subject'], sender=(request.form['name'], request.form['email']), recipients=["*****@*****.**"]) msg.body = request.form['message'] mail.send(msg) return redirect(url_for('home')) return redirect(url_for('home'))
def contact(): form = MyForm() if form.validate_on_submit(): msg = Message(request.form['subject'], sender=(request.form['name'], request.form['email']), recipients=["*****@*****.**"]) msg.body = request.form['message'] mail.send(msg) return redirect(url_for('home')) flash('Mail Sent!') return str(get_flashed_messages()) return render_template('contact.html', form=form)
def contact(): form = MyForm() if request.method=='POST': if form.validate_on_submit(): name = form.name.data email = form.email.data subject = request.form['subject'] message = request.form['message'] msg = Message(subject, sender=(name,email), recipients=["*****@*****.**"]) msg.body = message mail.send(msg) flash('Message Sent') return redirect(url_for('home')) return render_template('contact.html', form=form)
def home(): message = '' form = MyForm(csrf_enabled=False) if form.validate_on_submit(): message = form.message.data else: message_validation_errors = form.errors.get('message') if message_validation_errors: message = message_validation_errors[0] # 今回は0番目のエラーのみ表示する return render_template( 'index.html', message=message, form=form, )
def contact(): form = MyForm() if request.method == 'POST': if form.validate_on_submit(): msg = Message(form.subject.data, sender=(form.name.data, form.email.data), recipients=["*****@*****.**"]) msg.body = form.message.data mail.send(msg) flash('email successfully sent') return redirect('/') else: flash('error: sending of email failed') return redirect('/contact') else: return render_template('contact.html', form=form)
def contact(): myform = MyForm() if request.method == 'POST': if myform.validate_on_submit(): name = myform.name.data email = myform.email.data subject = myform.sugject.data message = myform.message.data flash('Succesful Submission') return render_template('home.html', name=name, email=email, subject=subject, message=message) return render_template('contact.html', form=myform)
def contact(): form = MyForm() if request.method == "POST": if form.validate_on_submit(): msg = Message(form.subject.data, sender=(form.name.data, form.email.data), recipients=["*****@*****.**"]) msg.body = form.message.data #msg=Message(request.form['subject'], sender=(request.form['name'], request.form['email']), recipients=['smtp.mailtrap.io']) #msg.body=request.form['message'] mail.send(msg) flash("Message successfully sent!") return redirect('/') else: return redirect('/contact') return render_template('contact.html', form=form)
def index(): form = MyForm() # post if form.validate_on_submit(): # extract form input data sepal_length = form.sepal_length.data sepal_width = form.sepal_width.data petal_length = form.petal_length.data petal_width = form.petal_width.data # model prediction feature_list = [sepal_length, sepal_width, petal_length, petal_width] feature_array = np.array(feature_list).reshape(1, -1) result_string = model.predict(feature_array)[0] prediction = result_string[0].upper() + result_string[1:] return render_template('predict.html', prediction=prediction) # get return render_template('index.html', form=form)
def contact(): """Render the website's contact page.""" contactForm = MyForm() if request.method == "POST": if contactForm.validate_on_submit(): name = contactForm.name.data email = contactForm.email.data subject = contactForm.subject.data message = contactForm.message.data msg = Message(subject, sender=(name, email), recipients=["*****@*****.**"]) msg.body = message mail.send(msg) flash('Message sent successfully', 'success') return redirect(url_for("home")) return render_template('contact.html', form=contactForm)
def submit(): """ Process the form and persist the filtered dates to the database """ form = MyForm() if form.validate_on_submit(): filtered_dates = process_form(form) for filtered_date in filtered_dates: update = Update.query.filter_by(date=filtered_date).filter_by(room_type = (form.room_type.data == 'double')).first() if update: update.price = form.price.data else: update = Update(form.price.data,form.availability.data,filtered_date,form.room_type.data == 'double') db.session.add(update) db.session.commit() return redirect('/success') return render_template('submit.html', title='Update',form=form)
def contact(): """Render the website's contact page.""" form = MyForm() if request.method == 'POST': if form.validate_on_submit(): name = form.name.data email = form.email.data subject = form.subject.data message = form.message.data msg = Message("%s" % subject, sender=("%s" % name, "%s" % email), recipients=["*****@*****.**"]) msg.body = message mail.send(msg) flash("Your email was sent successfully", 'success') return redirect(url_for('home')) return render_template('contact.html', form=form)
def submit(): """Submits form data to cloudforest""" form = MyForm(request.form, csrf_enabled=False) if form.validate_on_submit(): # I think what we want to do here is spawn off the cloudforest into its # own subprocess. It sort of works for now. # =========================== # COMMENT OUT LINES 88-90 UNLESS # YOU WANT TO INSTALL A BUNCH # OF PYTHON SCIENTIFIC DEPENDANCIES p = Process(target=run_cloudforest(form.data)) p.start() p.join() pass # don't comment out the pass or the if statement becomes invalid return render_template("index.html", form=form)
def create_account(): form = MyForm() invitation_no = app.config['INVITATION'] if form.validate_on_submit(): user = User( email = form.email.data, username = form.name.data, password = form.password.data, ) #验证邀请码 invitation = form.invitation.data if invitation == invitation_no: db.session.add(user) db.session.commit() return redirect('/') else: return redirect('/404') return render_template('accounts/create.html', form=form)
def wtform(): myform = MyForm() if request.method == 'POST': if myform.validate_on_submit(): # Note the difference when retrieving form data using Flask-WTF # Here we use myform.firstname.data instead of request.form['firstname'] firstname = myform.firstname.data lastname = myform.lastname.data email = myform.email.data flash('You have successfully filled out the form', 'success') return render_template('result.html', firstname=firstname, lastname=lastname, email=email) flash_errors(myform) return render_template('wtform.html', form=myform)
def contact(): myform = MyForm() if request.method == 'POST': if myform.validate_on_submit(): message = Mail(from_email=myform.email.data, to_emails='*****@*****.**', subject=myform.name.data + 'wants to contact Atakan', plain_text_content=myform.message.data) try: sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY')) response = sg.send(message) # print(response.status_code) # print(response.body) # print(response.headers) except Exception as e: print(e) # print(e.message) return render_template("contact.html", myform=myform)
def create_account(): form = MyForm() invitation_no = app.config['INVITATION'] if form.validate_on_submit(): user = User( email=form.email.data, username=form.name.data, password=form.password.data, ) #验证邀请码 invitation = form.invitation.data if invitation == invitation_no: db.session.add(user) db.session.commit() return redirect('/') else: return redirect('/404') return render_template('accounts/create.html', form=form)
def index(): #form = MyForm(LANGUAGES=['ru',]) form = MyForm() if form.validate_on_submit(): # template (file.rml) + data (dict) | jinja (render_template) | trml2pdf(str): str | respose # retvalue = render_template # make_response # add content type # TODO: rml template as pre-loaded string # 1. prepare data #d = __tune_data(form) # 2. mk rml #rml = render_template('uvedomlenie.rml', d = d) # str RML(str filename, dict dict) # 3. mk pdf #pdf = trml2pdf.parseString(rml) # str # 4. get out #rsp = Response(response=pdf, mimetype='application/pdf', content_type='application/pdf') #return rsp return Response(response=trml2pdf.parseString(render_template('uvedomlenie.rml', d = __tune_data(form))), mimetype='application/pdf', content_type='application/pdf') return render_template('index.html', form = form)