コード例 #1
0
ファイル: routes.py プロジェクト: Logicmn/osrs_exchange_index
def index():
    # Update the database
    #update()

    form = SubmitForm()
    print(form.errors)
    print(form.validate_on_submit())

    if form.validate_on_submit():
        item_name = str.lower(form.input.data)
        items = Item.query.filter(Item.name.contains(item_name)).all()

        if not items:
            print('unlisted')
            flash(
                'This item you have searched is not listed on the Grand Exchange.'
            )
            return render_template('index.html', form=form)

        else:
            return render_template('index.html',
                                   form=form,
                                   items=items,
                                   item_name=item_name,
                                   number_of_results=len(items))

    return render_template('index.html', form=form)
コード例 #2
0
def index():
    form = SubmitForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            infile = request.form['infile']
            outfile = request.form['outfile']
            address = request.form['address']
            iso = request.form['iso']
            key = request.form['key']
            geonames = request.form['geonames']
            usetools = request.form['usetools']
            encoding = request.form['encoding']
            resultsper = request.form['resultsper']
            buffer = request.form['buffer']
            batch_geocode.geocode_from_flask(infile=infile,
                                             iso=iso,
                                             outfile=outfile,
                                             keygm=key,
                                             geonames=geonames,
                                             address=address,
                                             usetools=usetools,
                                             encoding=encoding,
                                             resultspersource=resultsper,
                                             buffer=buffer)
            flash(
                'Your output file for input file, {}, usingtools {}, with {} results per source, and a buffer of {} '
                'is now ready to view at {}'.format(form.infile.data,
                                                    form.usetools.data,
                                                    form.resultsper.data,
                                                    form.buffer.data,
                                                    form.outfile.data))
            return render_template('index.html', title='Home', form=form)
        else:
            flash('Need to enter all required fields')
    return render_template('index.html', title='Home', form=form)
コード例 #3
0
def index():
    submit_form = SubmitForm()
    reset_form = ResetForm()
    if submit_form.validate_on_submit():
        old_recipe = submit_form.recipe.data
        new_recipe, replacements = vegeterizer.vegeterize(old_recipe)
        replacements = [{'ingr': key, 'r': val} for key, val in replacements.items()]
        return render_template('index.html', new_recipe=new_recipe, replacements=replacements, reset_form=reset_form, old_recipe=old_recipe)
    return render_template('index.html', submit_form=submit_form)
コード例 #4
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        flash("Submitting a post: {}".format(form.title.data))
        post = Posts(title=form.title.data, body=form.body.data)
        db.session.add(post)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('submit.html', title="NKOSL submit", form=form)
コード例 #5
0
ファイル: routes.py プロジェクト: Alex-Beng/NaiveOJ
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        post = Post(code=form.code.data, author=current_user)
        post.judge_code()
        db.session.add(post) 
        db.session.commit()
        flash("Submit successfully, check below")
        return redirect(url_for('user', username=current_user.username))
    return render_template('submit.html', title='Submit', form=form)
コード例 #6
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        uploaded_file = request.files['file'] # Get csv from request
        data = gb.preprocessing(uploaded_file) # Turn survey responses into graph
        agreement_graph = gb.build_graph(data)
        image = clq.make_seating(agreement_graph,form.chaotic.data) # Create the seating arrangement
        return render_template('result.html', title='Result', image=image, chaotic=form.chaotic.data)

    return render_template('submit.html', title='Submit', form=form)
コード例 #7
0
ファイル: routes.py プロジェクト: Bharath5324/thoracic_pred
def index():
    form = SubmitForm()
    if form.validate_on_submit():
        print("=============[ Entry Confirmation ]=============")
        x = form.data
        x.pop('csrf_token')
        x.pop('submit')
        flash(str(predictor.predict(x)))
        print(result)
        return redirect(url_for('result'))
    return render_template('form.html', form=form, title="Form")
コード例 #8
0
def submit():
    if not current_user.is_authenticated:
        flash('-You must be logged in to submit your artwork!')
        return redirect('/')
    form = SubmitForm()
    if form.validate_on_submit():
        print('hi')
        
        # TODO: submission back-end
    flash('|Artwork Submitted')
    return redirect('/')
コード例 #9
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        flash('Submission \'{}\' made successfully'.format(form.title.data))
        p = Post(title=form.title.data,
                 body=form.body.data,
                 user_id=current_user.id,
                 uname=current_user.username,
                 contact=current_user.email)
        db.session.add(p)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('submit.html', form=form)
コード例 #10
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        submission = Submission(title=form.title.data,
                                submitter=form.submitter.data,
                                submission=form.submission.data,
                                publishing_status="new")
        db.session.add(submission)
        db.session.commit()
        flash(
            'Your leak has been saved and is going to be reviewed. Thank you for leaking with <em>Leakyleaks</em>'
        )
        return redirect(url_for('process'))
    return render_template('submit.html', form=form)
コード例 #11
0
ファイル: routes.py プロジェクト: Githubplay12/IG_analyzer
def submit_user():

    form = SubmitForm()
    if form.validate_on_submit():
        verify_user = IgAccount.query.filter_by(
            username=form.username.data).first()
        if not verify_user:
            new_user = IgAccount(username=form.username.data)
            db.session.add(new_user)
            db.session.commit()
            flash(f'New account added to the database : {form.username.data}')
        return redirect(url_for('results', username=form.username.data))

    return render_template('submit.html', title='Submit Username', form=form)
コード例 #12
0
ファイル: routes.py プロジェクト: cmartin-cay/wordgame_solver
def index():
    form = SubmitForm()
    combo_word_list = []
    if form.validate_on_submit():
        letters = form.letters.data
        with open('app/static/words') as f:
            word_list = [word.rstrip("\n").lower() for word in f]
        word_list = {
            word
            for word in word_list
            if 8 >= len(word) >= 3 and not word.endswith("'s")
        }
        combo_word_list = solution(letters, word_list)
    return render_template('index.html',
                           combo_word_list=combo_word_list,
                           form=form)
コード例 #13
0
ファイル: routes.py プロジェクト: bg2345/movie_search
def index():

    form = SubmitForm()
    country = form.country.data

    if form.validate_on_submit():

        country = form.country.data
        print(form.country.data)

        return redirect(url_for('movies', country=country))

    return render_template('index.html',
                           title='Home',
                           country=country,
                           form=form)
コード例 #14
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        text = form.review.data
        matrix = tokenizer.texts_to_matrix([text])
        pred = np.argmax(model_rnn.predict(matrix.reshape((1, 1, n_words))) ) + 1
        if pred == 1:
            return render_template('star.html', user_image="https://dublinbookworm.files.wordpress.com/2015/07/1-star2.jpg?w=300&h=60")
        elif pred == 2:
            return render_template('star.html', user_image="https://dublinbookworm.files.wordpress.com/2015/07/2-star2.jpg?w=300&h=60")
        elif pred == 3:
            return render_template('star.html', user_image="https://dublinbookworm.files.wordpress.com/2015/07/3-star2.jpg?w=300&h=60")
        elif pred == 4:
            return render_template('star.html', user_image="https://dublinbookworm.files.wordpress.com/2015/07/4-star2.jpg?w=300&h=60")
        else:
            return render_template('star.html', user_image="https://dublinbookworm.files.wordpress.com/2015/07/5-star2.jpg?w=300&h=60")
    return render_template('submit.html', form=form)
コード例 #15
0
ファイル: routes.py プロジェクト: ns23/nuncio
def submit():  # The below code is ugly and so are you.
    """View function for the submit site, which contains a standard
       form. Creates initial variables for mutable variables like
       upvotes, downvotes and importance, to avoid any TypeErrors."""
    form = SubmitForm()
    if form.validate_on_submit():

        # Checks whether the topic exists, so as to not make identical topics.
        if check_topic_exists(form.topics.data):
            topic = Topic.query.filter_by(tag_name=form.topics.data).first()
            post = Post(title=form.title.data,
                        text=form.text.data,
                        user_id=current_user.id,
                        topics=[topic])

        elif not check_topic_exists(form.topics.data):
            post = Post(title=form.title.data,
                        text=form.text.data,
                        user_id=current_user.id,
                        topics=[Topic(tag_name=form.topics.data)])

        # Checks to see if post is link or url.
        if form.link.data == "":
            post.is_link = False

        else:
            post.is_link = True

        if form.link.data == "" and form.text.data == "":
            flash("Please input either a link or text, or both.")
            return redirect(url_for('submit'))

        post.upvotes = 1
        post.link = form.link.data
        post.downvotes = 0
        post.importance = 10
        post.hotness = post.get_hotness()
        post.score = post.get_score()
        db.session.add(post)
        db.session.commit()

        flash('You have now made a post!')
        return redirect(url_for('index'))
    return render_template('submit.html', title='Submit', form=form)
コード例 #16
0
ファイル: views.py プロジェクト: XieLeo11/vjcs-web
def addweibo():
    '''
    : addweibo: 增加一条任务
    '''
    form = SubmitForm()  # 生成任务编写表单

    if form.validate_on_submit():  # 若用户输入了合法的任务内容,则将用户的任务发送到数据库中

        # 1. 从表单中收集任务编写内容
        f = form.file.data
        filename = secure_filename(
            f.filename)  # filename一般可以伪装,因此必须使用secure_filename来进行处理

        post = Post(body=form.body.data,
                    user_id=current_user.id,
                    timestamp=datetime.utcnow(),
                    state=0)

        # 2. 将新的任务加入数据库的Post表单中
        db.session.add(post)
        db.session.commit()

        # 3. 将任务上传的视频保存到对应的文件夹: /weibofile/<weibo_id>
        save_dir = app.config['UPLOAD_FOLDER'] + '\\' + str(post.id)
        os.mkdir(save_dir)
        f.save(os.path.join(save_dir, filename))

        tar_post = Post.query.filter(Post.id == post.id).first()
        tar_post.filedir = 'img' + '/' + str(post.id) + '/' + filename
        db.session.commit()

        # 4. 将新的任务的id加入消息队列
        producer.produce(post.id)

        # 5. 提示用户信息,并跳转至应用首页
        flash('任务已成功提交')
        return redirect(url_for('index'))

    return render_template('addweibo.html',
                           form=form,
                           title='新任务',
                           isuser=current_user.is_authenticated)
コード例 #17
0
ファイル: routes.py プロジェクト: ModoUnreal/dopenet
def submit():
    """View function for the submit site, which contains a standard
       form. Creates initial variables for mutable variables like
       upvotes, downvotes and importance, to avoid any TypeErrors."""
    form = SubmitForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data,
                    text=form.text.data,
                    user_id=current_user.id,
                    topics=[Topic(tag_name=form.topics.data)])
        post.upvotes = 1
        post.downvotes = 0
        post.importance = 1
        post.score = post.get_score()
        db.session.add(post)
        db.session.commit()

        flash('You have now made a post!')
        return redirect(url_for('index'))
    return render_template('submit.html', title='Submit', form=form)
コード例 #18
0
def index():

    form = SubmitForm()
    if form.validate_on_submit():
        try:
            flash('Submitted for number {} of {}'.format(
                form.usernum.data, form.usercity.data))
            place = form.usercity.data
            user_num = '+1' + form.usernum.data
            weather = Weather(place, API_ID)
            send_message = Send(MY_ACCOUNT, MY_TOKEN, user_num)
            send_message.send_message(weather.city, weather.current,
                                      weather.high, weather.low,
                                      weather.condition)

            return redirect(url_for('index'))
        except:
            flash(
                'ERROR: City Name Not Spelled Correctly! e.g. los angeles, not losangeles'
            )
            return redirect(url_for('index'))
    else:
        return render_template('index.html', form=form)
コード例 #19
0
def submit():
    form = SubmitForm()
    if form.validate_on_submit():
        if form.flag.data == "steg{wh1t3 Is c0Ol}":
            flash("Congrats!You Completed Your Challenge")
        elif form.flag.data == "steg{g_o_t_y_o_u_r_f_l_a_g}":
            flash("Congrats!You Completed Your Challenge")
        elif form.flag.data == "steg{h1ng3d It}":
            flash("Congrats!You Completed Your Challenge")
        elif form.flag.data == "steg{p13sa'nt s0und m'ak3s a' dAy}":
            flash("Congrats!You Completed Your Challenge")
        elif form.flag.data == "steg{H3R3_15_y0ur_fl4g}":
            flash("Congrtas!You Completed Your Challenge")
        elif form.flag.data == "steg{StrAnGe Idea}":
            flash("Congrtas!You Completed Your Challenge")
        elif form.flag.data == "steg{C0OL_Y0U_4R3_1337}":
            flash("Congrats!You Completed Your Challenge")
        elif form.flag.data == "steg{3NCRYPTI0N5_4R3_C00L}":
            flash("Congrats!You Completed Your Challenge")
        else:
            flash("Try Again!Better Luck")

    app.logger.debug(app.config.get("ENV"))
    return render_template('submit.html', title='Steganography CTF', form=form)
コード例 #20
0
def submit():
    if not can_submit():
        return render_template('submissions-closed.html',
                               title='Submissions are closed!'), 403

    form = SubmitForm(meta={'csrf': False})
    if form.validate_on_submit():
        t_priv = form.private_id.data
        team = Team.query.filter(Team.private_id == t_priv).first()
        t_id = team.id
        t_name = team.name

        # Find previous submission time (if exists)
        prev_sub = Submission.query.filter(
            Submission.team_id == t_id).order_by(
                Submission.sub_time.desc()).first()
        prev_time = datetime.strptime(ORIG_TIME, DB_TIME_FORMAT)
        if prev_sub:
            prev_time = prev_sub.sub_time

        # Rate limit submissions
        now = datetime.utcnow()
        if app.config['SUBMIT_DELAY']:
            diff = (now - prev_time).total_seconds()
            if diff < app.config['SUBMIT_DELAY']:
                # Status code: 429 Too Many Requests
                return render_template(
                    'rate-limit.html',
                    time_diff=diff,
                    sub_delay=app.config['SUBMIT_DELAY']), 429

        f = form.file.data
        now_str = now.strftime(ZIP_TIME_FORMAT)

        filename = 'team_{}_{}.zip'.format(t_id, now_str)
        location = os.path.join(app.config['SUBMIT_DIR'], filename)
        os.makedirs(os.path.dirname(location), exist_ok=True)
        f.save(location)

        h = ''
        with open(location, "rb") as f:
            bytes = f.read()
            h = hashlib.sha256(bytes).hexdigest()

        # XXX: stages; we don't need a check here, since submissions with .buy
        # will be rejected outright
        # Reject submissions that try to buy more boosters than they can afford
        num_coins = get_balance(t_id)
        good_purchase, total, extra = False, 0, None
        try:
            good_purchase, total, extra = validate_booster_purchase(
                num_coins, location)
        except UnicodeDecodeError:
            return render_template('boosters-fail.html', not_decoded=True)
        if extra is not None and len(extra) > 0:
            return render_template('boosters-fail.html', extra=extra)
        if not good_purchase:
            # Status code: 402 Payment Required
            return render_template('boosters-fail.html',
                                   num_coins=num_coins,
                                   total=total), 402

        # Schedule for grading
        # TODO: this will just timeout if the broker is offline
        spent_coins = total
        grade.delay(t_id, t_priv, t_name, now_str, filename, h, spent_coins)

        # Register submission in database
        sb = Submission(team_id=t_id, name=filename, hash=h, sub_time=now)
        db.session.add(sb)
        db.session.commit()

        # Acknowledge submission to team
        gd = grades_dir(t_priv)
        os.makedirs(gd, exist_ok=True)

        sf = os.path.join(gd, SUBMISSIONS_FILE)
        with open(sf, 'a+') as f:
            f.write('{} -> {}\n'.format(now_str, h))

        # Create team identifiers in case they don't exist
        nf = os.path.join(gd, TEAM_NAME_FILE)
        with open(nf, 'w') as f:
            f.write('{}\n'.format(t_name))

        idf = os.path.join(gd, TEAM_ID_FILE)
        with open(idf, 'w') as f:
            f.write('{}\n'.format(t_id))

        team_folder = '/grades/{}/'.format(t_priv)

        return render_template('submitted.html',
                               filename=filename,
                               hash=h,
                               team_folder=team_folder)

    return render_template('submit.html', title='Submit a solution', form=form)