-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
92 lines (50 loc) · 1.7 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from cmd import IDENTCHARS
from flask import Flask, render_template, redirect, url_for
from wtforms import StringField, SubmitField, PasswordField
from wtforms.validators import InputRequired, Length
from flask_wtf import FlaskForm
from flask_bootstrap import Bootstrap
from flask_sqlalchemy import SQLAlchemy
import os
from datetime import datetime
from flask_migrate import Migrate
from random import *
app = Flask(__name__)
Bootstrap(app)
SECRET_KEY = os.urandom(32)
app.config.from_object(os.environ['APP_SETTINGS'])
app.config['SECRET_KEY'] = SECRET_KEY
db = SQLAlchemy(app)
HTTP_API = os.environ['HTTP_API']
def random_integer():
min_ = 1000
max_ = 10000
rand = randint(min_, max_)
return rand
class User(db.Model):
__tablename__= 'telegram_ari'
id=db.Column( db.Integer, primary_key = True)
ID = db.Column(db.String(50), default=random_integer, unique=True)
email = db.Column(db.String(50))
def __init__(self, ID, email):
self.ID = ID
self.email = email
class Regester(FlaskForm):
email = StringField('Email', validators=[InputRequired(), Length(max=200)])
ID = StringField(randint(1000, 10000))
migrate = Migrate(app, db)
db.create_all()
@app.route('/regester', methods=['POST', 'GET'])
def regist():
form = Regester()
if form.validate_on_submit():
user = User(
ID = form.ID.data,
email= form.email.data
)
db.session.add(user)
db.session.commit()
return '<h1> Succsesful Regestration</h1>'
return render_template('index.html', form=form)
if __name__=="__main__":
app.run(debug=True)