app.py - from flask import Flask redirect url_for request,render_template app = Flask_name import smtplib import psycopg2 conn =

app.py - from flask import Flask redirect url_for...

This preview shows page 1 out of 1 page.

from flask import Flask, redirect, url_for, request,render_template app = Flask(__name__) import smtplib import psycopg2 conn = psycopg2.connect(database="postgres", user = "postgres", password = "12345", host = "127.0.0.1", port = "5432") print("Opened database successfully") @app.route('/enternew') def new_student(): #return render_template('student.html') return render_template('student.html') @app.route('/addrec', methods=['POST', 'GET']) def addrec(): if request.method == 'POST': try: nm = request.form['nm'] addr = request.form['add'] city = request.form['city'] pin = request.form['pin'] cur = conn.cursor() cur.execute("INSERT INTO students
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Spring '16
  • PostgreSQL, 127.0.0.1, #Return, flask import Flask, 5432

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture