Hello Im new to flask and python, i tried redirecting my script to go to something.html as it was apresenting a 404 i decided to run a hello world and did not work.
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
from flask import Flask
from flask import request
from flask import url_for
from flask import redirect
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI']= 'postgre://postgres:*****@localhost/web'
db = SQLAlchemy(app)
class Rent(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(200) , unique=True)
sug1 = db.Column(db.String(200) , unique =True)
sug2 = db.Column(db.String(200) , unique = True)
sug3 = db.Column(db.String(200), unique = True)
def __init__ (self,email,sug1,sug2,sug3):
self.email = email
self.sug1 = sug1
self.sug2 = sug2
self.sug3 = sug3
def __repr__(self):
return '<User %>' % self.email
@app.route('/hello')
def index():
return "Hello"
@app.route('/resumo', methods=['POST'])
def pesquisa():
rent = Rent(request.form['email'],request.form['sug1'],request.form['sug2'],request.form['sug3'])
db.session.add(rent)
db.session.commit()
return redirect(url_for('index'))
if __name__ == "__main__":
app.run(port=5500)
Aucun commentaire:
Enregistrer un commentaire