Exemplo n.º 1
0
def insert_number():
    data = []
    numbers = json.load(open('data/numbers_data.json'))['data']
    try:
        for n in numbers:
            row = Number(name=n['name'],
                         number=n['number'],
                         on_campus=n['onCampus'],
                         all_day=n['allDay'],
                         description=n['description'])
            db.session.add(row)
            db.session.commit()
    except:
        print "Error: couldn't add new number.", sys.exc_info()[1]
Exemplo n.º 2
0
def home():
    form = DataForm()
    print("OH YES")
    if form.validate_on_submit():
        print("OH AGAIN")
        number_from = form.number_from.data
        number_to = form.number_to.data
        email = form.email.data

        with app.app_context():
            number = Number(email=email,
                            number_from=number_from,
                            number_to=number_to)
            db.session.add(number)
            db.session.commit()
            flash("Successfully sent message, wait a few minutes to recieve")

        user_data_dict[email] = Stalk(email)
        user_data_dict[email].search(email)
        user_data_dict[email].write(user_data_dict[email].results)

    return render_template("index.jinja2", form=form)
Exemplo n.º 3
0
def insert_count(session, count):
    insert = Number(count=count)
    session.add(insert)
    session.commit()
Exemplo n.º 4
0
from flask import render_template, Flask, url_for, request
import random
from models import Number

app = Flask("Guess")

gen_number = Number(score=random.randrange(1, 100))
stored_number = gen_number.put()
count = 0


@app.route('/', methods=['GET', 'POST'])
def index():
    global gen_number
    global stored_number
    global count
    input_number = request.form.get("number")
    if request.method == 'POST':
        try:
            if int(input_number) > stored_number.get().score:
                reply = "Your input is greater, you entered %s. Try again" % (
                    input_number)
                img = 'sad'
                count += 1
                #print stored_number.get()
                return render_template('index.html', reply=reply, img=img)
            elif int(input_number) < stored_number.get().score:
                reply = "Your input is lesser, you entered %s. Try again" % (
                    input_number)
                img = 'sad'
                count += 1