def svm_view(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = myForm(request.POST) # check whether it's valid: if form.is_valid(): result = svmmethode(form.cleaned_data['failure'], form.cleaned_data['fedu'], form.cleaned_data['schoolsup'], form.cleaned_data['medu'], form.cleaned_data['goout'], form.cleaned_data['freetime']) # process the data in form.cleaned_data as required # ... print("===========================================") print(result) # redirect to a new URL: if result[0] == 1: return HttpResponseRedirect("/echec") else: return HttpResponseRedirect("/success") # if a GET (or any other method) we'll create a blank form else: form = myForm() return render(request, 'name_svm.html', {'form': form})
def knn_view(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = myForm(request.POST) # check whether it's valid: if form.is_valid(): result = knnmethode( form.cleaned_data['medu'], form.cleaned_data['fedu'], form.cleaned_data['relation_familiale'], form.cleaned_data['freetime'], form.cleaned_data['goout'], form.cleaned_data['consomation_alcool'], form.cleaned_data['sante'], form.cleaned_data['age'], form.cleaned_data['absences'], form.cleaned_data['mjob'], form.cleaned_data['fjob'], form.cleaned_data['raison']) # process the data in form.cleaned_data as required # ... print("===========================================") print(result) # redirect to a new URL: if result[0] == 1: return HttpResponseRedirect("/echec") else: return HttpResponseRedirect("/success") # if a GET (or any other method) we'll create a blank form else: form = myForm() return render(request, 'name_knn.html', {'form': form})
def form(): form = myForm() if request.method == "POST": db.db.collection.insert_one({"message": request.form['message']}) return '<h1> The message is : {} '.format(request.form['message']) else: return render_template("form.html", form=form)
def upload(): form = myForm() if request.method == 'GET': return redirect('/index/') elif request.method == 'POST': fil = request.files['file'] fname = secure_filename(fil.filename) # save_path = app.config['UPLOAD_FOLDER'] if fname.strip() == '': flash("Please select file.") return redirect('/index/') if 'xlsx' in fname or 'xls' in fname: fname = 'tmp.xlsx' save_path = app.config['TMP_FOLDER'] fil.save(os.path.join(save_path, fname)) return redirect('/select_column/') elif '.xml' in fname: fname = 'tmp.xml' save_path = app.config['TMP_FOLDER'] fil.save(os.path.join(save_path, fname)) return redirect('/process/') else: fname = 'rawtext.txt' save_path = app.config['TMP_FOLDER'] fil.save(os.path.join(save_path, fname)) return redirect('/process/')
def process(): form = myForm() link = '' label = '' if request.method == 'GET': return render_template('process.html', form=form, link='', label='') if request.method == 'POST': label = 'DownloadResult' rawtext = open(os.path.join(app.config['TMP_FOLDER'], 'rawtext.txt')).readlines() if form.fre.data == 'ex': link = u'/result/rawtext.txt' elif form.fre.data == 'fr': qacorpus.frequency(rawtext) link = u'/result/frequency.txt' elif form.fre.data == 'al': synonymy.get_wiki_synonymy(rawtext) link = u'/result/aliases.txt' elif form.fre.data == 'sy': synonymy.get_hit_synonymy(rawtext) link = u'/result/synonymy.txt' elif form.fre.data == 'xml': frequency.statistics() link = u'/result/CfgKeywordWeight.properties' return render_template('process.html', form=form, link=link, label=label)
def get(self,request): form = myForm() services = Service.objects.all() context = {'services':services, 'form':form } return render(request,'index.html',context)
def post(self,request): form = myForm(request.POST) if form.is_valid(): text = form.cleaned_data['text'] option = form.cleaned_data['option'] context = {'text':text, 'option':option } return render(request,'response.html',context)
def submitted(request): # RestaurantName=" sfsfasda" if request.method == "POST": MyLoginForm = myForm(request.POST) if MyLoginForm.is_valid(): name = MyLoginForm.cleaned_data['tags'] else: name = "not found" else: MyLoginForm = myForm() imgpath = "myapp/img/" + name + ".jpeg" foodimg = "myapp/img/" + name + "food.jpeg" modelObject = restaurent.objects.get(name=name) desc = modelObject.review_text return render(request, 'myapp/hotelPage.html', { "name": name, "imgpath": imgpath, "desc": desc, "foodimg": foodimg })
def contact(): form = myForm(request.form) if request.method == 'POST' and form.validate(): message = Message(form.subject.data, sender=(form.name.data, form.email.data), recipients=["*****@*****.**"]) message.body = form.Message.data mail.send(message) flash("Your message has been sent") return render_template('home.html') else: return render_template('contact.html', form=form, addtext='(Required)')
def contact(): 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(subject, sender=(name,email), recipients = ["*****@*****.**"]) msg.body = form.msg.data mail.send(msg) flash("Message Sent Succesfully!") return redirect('/') return render_template('contact.html',form = form)
def select_column(): form = myForm() if request.method == 'POST': if form.colnum.data != '': qacorpus.getrawtext(columnnum=int(form.colnum.data) - 1) return redirect('/process') else: flash("Please select column." + form.colnum.data) return render_template( 'xls.html', form=form, ) return render_template( 'xls.html', form=form, )
def greeting_page(): form = myForm() return render_template('form.html', form=form)
def index(): form = myForm() return render_template('index.html', form=form)