Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #share data
- #endpoint - точки входа
- #flask, django, aiohttp
- #pip install flask
- #python -m pip install flask
- from flask import Flask, render_template, request
- from db import add_user
- from sqlalchemy.exc import IntegrityError
- app = Flask(__name__)
- # app=decorator
- @app.route('/', methods=['GET', 'POST'])
- def index():
- if request.method == 'GET':
- return render_template('index.html')
- else:
- email = request.form['email']
- username = request.form['username']
- password = request.form['pw']
- password_check = request.form['pw2']
- if password != password_check:
- return render_template('index.html', error='password_error')
- try:
- add_user(username, email, password)
- except IntegrityError:
- return render_template('index.html', error='already_exists')
- return 'User was successfully signed up'
- @app.route('/<name>')
- def hello_ivana(name):
- return render_template('index_ivana.html', name=name)
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement