flask.request.form

Here are the examples of the python api flask.request.form taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1105 Examples 7

5 Source : routes.py
with Apache License 2.0
from interuss

def request_rid_poll():
  if 'area' not in flask.request.form:
    flask.abort(400, 'Missing area')

  try:
    area = geo.make_latlng_rect(flask.request.form['area'])
  except ValueError as e:
    flask.abort(400, str(e))

  flights_result = fetch.rid.all_flights(
    context.resources.dss_client, area,
    flask.request.form.get('include_recent_positions'),
    flask.request.form.get('get_details'),
    flask.request.form.get('enhanced_details'))
  log_name = context.resources.logger.log_new('clientrequest_getflights', flights_result)
  return flask.redirect(flask.url_for('logs', log=log_name))


@webapp.route('/favicon.ico')

5 Source : flask_main.py
with GNU General Public License v3.0
from kearch

def update_config():
    update = dict()
    if 'connection_policy' in flask.request.form:
        update['connection_policy'] = flask.request.form['connection_policy']
    if 'host_name' in flask.request.form:
        update['host_name'] = flask.request.form['host_name']
    db_req = KearchRequester(
        DATABASE_HOST, DATABASE_PORT, conn_type='sql')
    db_req.request(path='/me/db/set_config_variables',
                   payload=update, method='POST')
    return flask.redirect(flask.url_for("index"))


@app.route('/me/admin/approve_a_connection_request', methods=['POST'])

5 Source : flask_main.py
with GNU General Public License v3.0
from kearch

def update_config():
    update = dict()
    if 'connection_policy' in flask.request.form:
        update['connection_policy'] = flask.request.form['connection_policy']
    if 'host_name' in flask.request.form:
        update['host_name'] = flask.request.form['host_name']
    if 'engine_name' in flask.request.form:
        update['engine_name'] = flask.request.form['engine_name']

    db_req = KearchRequester(
        DATABASE_HOST, DATABASE_PORT, conn_type='sql')
    db_req.request(path='/sp/db/set_config_variables',
                   payload=update, method='POST')
    return flask.redirect(flask.url_for("index"))


@app.route("/")

3 Source : auth.py
with MIT License
from 9b

def login():
    """Handle the login process."""
    form = LoginForm(request.form)
    if request.method == 'POST' and form.validate():
        c = mongo.db[app.config['USERS_COLLECTION']]
        user = c.find_one({"username": form.username.data})
        logger.debug("User: %s" % user)
        if user and User.validate_login(user['password'], form.password.data):
            user_obj = User(user)
            login_user(user_obj, remember=True)
            next = request.args.get('next')
            return redirect(next or url_for('core.root'))
    errors = ','.join([value[0] for value in form.errors.values()])
    return render_template('login.html', message=errors)


@core.route('/logout')

3 Source : generic.py
with MIT License
from 9b

def account_change_password():
    """Update account password."""
    form = ChangePasswordForm(request.form)
    if form.validate():
        if 'user_id' not in request.form:
            return jsonify({'success': False,
                            'error': 'ID not found in edit!'})
        edit_id = paranoid_clean(request.form.get('user_id'))
        c = mongo.db[app.config['USERS_COLLECTION']]
        item = {'password': generate_password_hash(form.password.data)}
        c.update({'_id': ObjectId(edit_id)}, {'$set': item})
        return redirect(url_for('core.settings'))
    errors = ','.join([value[0] for value in form.errors.values()])
    return jsonify({'errors': errors})


@core.route('/admin/settings', methods=['POST'])

3 Source : generic.py
with MIT License
from 9b

def admin_save_settings():
    """Save settings for the admin accounts."""
    form = AdminForm(request.form)
    if not form.validate():
        errors = ','.join([value[0] for value in form.errors.values()])
        return jsonify({'errors': errors})

    c = mongo.db[app.config['GLOBAL_COLLECTION']]
    c.remove(dict())
    item = {'email': form.email.data, 'password': form.password.data}
    c.insert(item)
    #  This will take the new credentials and load them into the config file
    ga = GoogleAlerts(item['email'], item['password'])
    #  Assumed a change to the credentials means killing the old session
    if os.path.exists(SESSION_FILE):
        os.remove(SESSION_FILE)
    return redirect(url_for('core.settings'))

3 Source : routes.py
with MIT License
from adri711

def add_contact():
    contact = User.query.filter(User.username==request.form['username']).first()
    if contact and int(contact.id) == int(current_user.get_id()):
        contact = None #
    return jsonify({'name': contact.username, 'id': contact.id, 'img_url': url_for('static', filename='imgs/defaultuser-icon.png')}) if contact and contact.id != current_user.get_id() else jsonify({'error': 'user not found.'})

@app.route('/retrieve-directmessages/  <  user_id>', methods=['POST'])

3 Source : routes.py
with MIT License
from adri711

def add_note():
    if request.form['note_title'] and request.form['note_text'] and request.form['channel_id']: 
        note_title = request.form['note_title']
        note_text = request.form['note_text']
        note_channel_id = request.form['channel_id']
        if request.files["note_image"]:
            image = request.files["note_image"]
            filename = secure_filename(image.filename)
            image.save(os.path.join(app.config['IMAGE_UPLOADS'], filename))
        new_note = Note(author_id=current_user.get_id(), title=note_title, note_text=note_text,note_imgs=filename, channel_id=note_channel_id)
        db.session.add(new_note)
        db.session.commit()
        return jsonify({'new_note': {'note_title':new_note.title, 'note_id': new_note.id, 'note_text': new_note.note_text, 'note_img': url_for('static', filename='imgs/' + new_note.note_imgs)}})
    else:
        pass

@app.route('/classroom-settings/  <  classroom_id>', methods=['POST'])

3 Source : routes.py
with MIT License
from adri711

def join_team():
    team_code = request.form['code']
    if team_code:
        classroom_id = Classroom.query.filter(Classroom.code==team_code).first()
        if classroom_id:
            new_membership = Membership(user_id=current_user.get_id(), classroom_id=classroom_id.id, role='regular')
            db.session.add(new_membership)
            db.session.commit()
            return jsonify({'result': {'id': classroom_id.id,
                'name': classroom_id.name}, 
                'url_for_img': url_for('static', filename='imgs/'+ classroom_id.image_file)})
        return jsonify({'error': "given code has either expired or is not valid"})
    return jsonify({'error': 'given code is invalid'})

@app.route('/retrieve-notes/  <  channel>', methods=['POST'])

3 Source : routes.py
with MIT License
from adri711

def add_assignment():
    get_date = parser.parse(request.form['assignment_date'])
    new_assignment = Assignment(author_id=current_user.get_id(), due_date=get_date, assignment_text=request.form['assignment_text'], channel_id=request.form['channel_id'])
    db.session.add(new_assignment)
    db.session.commit()
    return jsonify({'id': new_assignment.id, 'text': new_assignment.assignment_text, 'duedate': new_assignment.due_date})

@app.route('/homework-submit', methods=['POST'])

3 Source : app.py
with GNU General Public License v3.0
from adriancaruana

def my_form_post():
    username = request.form["username-input"]
    print(f"Getting data for user: {username}")
    return redirect(
        url_for(
            "user",
            username=username,
        )
    )


@app.route("/user/  <  username>")

3 Source : app.py
with MIT License
from afroisalreadyinu

def add_todo():
    new_todo = TodoItem(what_to_do=request.form['what-to-do'])
    db.session.add(new_todo)
    db.session.commit()
    return redirect("/")

if __name__ == "__main__":

3 Source : authentication.py
with GNU General Public License v3.0
from akhefale

def register_union():
    form = RegisterUnionForm(request.form)
    if request.method == 'POST':
        union_name = form.union_name.data
        password = form.password.data

        union = Union(union_name, hash_password(password))
        db.session.add(union)
        # commit to database
        db.session.commit()

        msg = 'Your union is now registered and can be accessed by other users'
        return render_template('index.html', msg=msg)
    return render_template('register-union.html',
        form=form, unions=Union.print())


# user login
@view.route('/login', methods=['GET', 'POST'])

3 Source : webapp.py
with MIT License
from AkshatSh

def index():
    search = VideoSearchForm(request.form)
    if request.method == 'POST':
        return search_results(search)
    
    return render_template('index.html', form=search)

@app.route('/results')

3 Source : user.py
with MIT License
from alectrocute

def charge():
    # Amount in cents
    amount = 500
    customer = stripe.Customer.create(email=current_user.email, source=request.form['stripeToken'])
    charge = stripe.Charge.create(
        customer=customer.id,
        amount=amount,
        currency='usd',
        description='Service Plan'
    )
    user = models.User.query.filter_by(email=current_user.email).first()
    user.paid = 1
    db.session.commit()
    # do anything else, like execute shell command to enable user's service on your app
    return render_template('user/charge.html', amount=amount)

@app.route('/api/payFail', methods=['POST', 'GET'])

3 Source : server.py
with GNU General Public License v3.0
from alejndalliance

def login():
    """Attempts to log the user in"""

    from werkzeug.security import check_password_hash

    username = request.form['user']
    password = request.form['password']

    user = db['users'].find_one(username=username)
    if user is None:
        return redirect('/error/invalid_credentials')

    if check_password_hash(user['password'], password):
        session_login(username)
        return redirect('/tasks')

    return redirect('/error/invalid_credentials')

@app.route('/register')

3 Source : server.py
with GNU General Public License v3.0
from alejndalliance

def addcatsubmit():
    try:
        name = bleach.clean(request.form['name'], tags=[])
    except KeyError:
        return redirect('/error/form')
    else:
        categories = db['categories']
        categories.insert(dict(name=name))
        return redirect('/tasks')

@app.route('/editcat/  <  id>/', methods=['GET'])

3 Source : server.py
with GNU General Public License v3.0
from alejndalliance

def editcatsubmit(catId):
    try:
        name = bleach.clean(request.form['name'], tags=[])
    except KeyError:
        return redirect('/error/form')
    else:
        categories = db['categories']
        categories.update(dict(name=name, id=catId), ['id'])
        return redirect('/tasks')

@app.route('/editcat/  <  catId>/delete', methods=['GET'])

3 Source : app.py
with MIT License
from AlexEidt

def search():
    # Search used for the Search Bar in right corner of the Nav Bar
    course = request.form['name'].upper().replace(' ', '')
    if course in CATALOGS.index:
        # Create the Prerequisite Tree if necessary for the course page
        svg = create_tree(CATALOGS, course, request.url_root)
        return render_template(
            'course.html',
            svg=svg,
            course=course,
            course_data=CATALOGS.loc[course].to_dict()
        )
    return redirect(url_for('index'))


@app.route('/_get_tree/', methods=['POST'])

3 Source : app.py
with MIT License
from AlexEidt

def _keyword_search():
    # Used for the case-insensitive keyword search 
    keyword = request.form['keyword'].lower()
    lower = CATALOGS['Description'].str.lower()
    courses = CATALOGS[lower.str.contains(keyword, regex=False)].to_dict(orient='index')
    return jsonify({'matches': courses})


@app.route('/get_geocode/', methods=['POST'])

3 Source : app.py
with MIT License
from AlexEidt

def create_schedule():
    # Creates all possible schedules based on the courses entered by the user
    courses = request.form['course'].strip(',').split(',')
    global course_options
    course_options = get_combinations(courses)
    try:
        next_option = next(course_options)
    except StopIteration:
        next_option = None
    return jsonify({'option': next_option, 'coords': GEOCODED})


@app.route('/get_schedules/', methods=['POST'])

3 Source : example_bp.py
with MIT License
from alexOarga

def example_delay_task():

    request_data = request.form

    task = example_task.delay()

    return "celery task initiated!"

3 Source : ascii_ctf.py
with BSD 2-Clause "Simplified" License
from andreafioraldi

def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    
    form = LoginForm(request.form)
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.login.data).first()
        if user is None or not user.verify_password(form.password.data):
            return 'Invalid username or password'
         
        login_user(user)
        return redirect(url_for('index'))
    
    return render_template('login.html', form=form)

@app.route('/logout')

3 Source : app.py
with MIT License
from AnhellO

def parse_form():
    x = {}
    d = request.form
    for key in d.keys():
        value = request.form.getlist(key)
        for val in value:
            x[key] = val

    return x

def mongo_find(query):

3 Source : SparkOperator.py
with Apache License 2.0
from arakat-community

def getFilesFromHDFS():
    try:
       print(request.form['path'])
       os.system("hdfs dfs -get "+ request.form['path']+" ./hdfs-file/")
       return "True"
    except:
       return "False"


def getHDFSContentParquet(path):

3 Source : SparkOperator.py
with Apache License 2.0
from arakat-community

def getTableColumns():
    filePath = request.form["file"]
    content = readData(filePath)
    return json.dumps(content.columns)


@app.route('/get-table-columns-with-types',methods=['POST'])

3 Source : SparkOperator.py
with Apache License 2.0
from arakat-community

def getTableColumnsWithTypes():
    filePath = request.form["file"]
    content = readData(filePath)
    typeList = content.dtypes
    tableInfoJson=[]
    headers=["column","columnType"]
    index=1
    for type in typeList:
        cell={}
        i=0
        for header in headers:
            cell[header]=type[i]
            i=i+1
        tableInfoJson.append(cell)
        index = index+1

    return json.dumps(tableInfoJson)

@app.route('/test',methods=['GET'])

3 Source : SparkOperator.py
with Apache License 2.0
from arakat-community

def runSparkJob():
    try:
       command = request.form['command'].split()
       fileName=request.form['file']
       fileName = "log_"+fileName
       file = open("/spark_logs/"+fileName, "w")
       for line in run_command(command):
           file.write(line)
       file.close()
       return "True"
    except:
       return "False"


def convert(data):

3 Source : cmd_exec.py
with MIT License
from archivy

    def __init__(self, fimeta):
        super().__init__(fimeta)
        if self.param.form_type == "text":
            self.link_name = request.form[self.key]
            # set the postfix to name name provided from form
            # this way it will at least have the same extension when downloaded
            self.file_suffix = request.form[self.key]
        else:
            # hidden no preferred file name can be provided by user
            self.file_suffix = ".out"

    def save(self):

3 Source : hello.py
with GNU General Public License v3.0
from ArnavChawla

def check_key():
    print(request.form)
    print(request.form['key'])
    data ={
            'key':request.form['key']
    }
    r = requests.post("http://www.redmond2828.club/check_auth", data=data)
    print(r.text)
    if(r.text == "true"):
        print("hi")
        return render_template('blank_page.html')
    return render_template('activation.html')
@app.route('/check_auth',methods=['POST'])

3 Source : hello.py
with GNU General Public License v3.0
from ArnavChawla

def get_form():
    print(request.form)
    filePath = "./profiles/"+request.form["profile"]+".json"
    p = open(filePath, 'w+')
    json.dump(request.form, p)
    p.close()
    return render_template('blank_page.html')
@app.route('/task_create')

3 Source : evaluate_service.py
with Apache License 2.0
from Ascend

    def parse_paras(self):
        """Parse the parameters in the request from the client."""
        self.framework = request.form["framework"]
        self.backend = request.form["backend"]

    def upload_files(self):

3 Source : api.py
with Apache License 2.0
from asreview

def api_update_project_info(project_id):  # noqa: F401
    """Get info on the article"""

    project_name = request.form['name']
    project_description = request.form['description']
    project_authors = request.form['authors']

    project_id_new = update_project_info(
        project_id,
        project_name=project_name,
        project_description=project_description,
        project_authors=project_authors)

    return jsonify(id=project_id_new)


@bp.route('/datasets', methods=["GET"])

3 Source : api.py
with Apache License 2.0
from asreview

def api_update_classify_instance(project_id, doc_id):
    """Update classification result."""

    doc_id = request.form['doc_id']
    label = request.form['label']

    move_label_from_labeled_to_pool(project_id, doc_id)
    label_instance(project_id, doc_id, label, retrain_model=True)

    response = jsonify({'success': True})
    response.headers.add('Access-Control-Allow-Origin', '*')
    return response


@bp.route('/project/  <  project_id>/get_document', methods=["GET"])

3 Source : main.py
with MIT License
from bastiancy

def user_login():
    username = request.form['username']

    if not username or username not in USERS:
        raise KeyError('username not valid!')

    user = USERS[username]
    password = request.form['password']

    if not password or password != user['password']:
        raise KeyError('password not valid!')

    content = {'token': username, 'name': user['name']}
    return Response(json.dumps(content), mimetype='application/json')


@web.route("/api/user/logout")

3 Source : security_api.py
with Apache License 2.0
from bbc

    def authorization_post(self):
        owner = g.owner
        if request.form:
            if "confirm" in request.form.keys() and request.form['confirm'] in ["true", "True", True]:
                grant_user = owner
        elif request.is_json:
            if "confirm" in request.json and request.json['confirm'] in ["true", "True", True]:
                grant_user = owner
        else:
            grant_user = None
        return authorization.create_authorization_response(grant_user=grant_user)

    @route(AUTH_VERSION_ROOT + AUTHORIZATION_ENDPOINT + '/', methods=['GET'], auto_json=False)

3 Source : home.py
with MIT License
from BeamIO-Inc

def main():
    try:
        chain_name = json.loads(request.form['chain'])['chain_name']
    except:
        return make_response('Chain name does not exist in request form', 400)

    check = check_chain_request_form(request, chain_name, path)
    if not isinstance(check, dict):
        return check
    response = process_chain_request(check, path)

    return response


@home.route('/chain_run_status/  <  status_key>/', methods=['POST'])

3 Source : routes.py
with MIT License
from bitcynth

def whois_post():
    if not 'query' in request.form:
        return 'error'
    query = request.form['query']
    data = query_whois(query)
    return render_template('whois_response.html', data=data, title='WHOIS Result')

@app.route('/api/v1/whois/query/  <  query>', methods=['GET'])

3 Source : loki.py
with MIT License
from Bitwise-01

def control_ssh():
    if not "cmd" in request.form:
        return jsonify({"resp": "Please provide cmd argument"})

    cmd = request.form["cmd"].strip()

    if not "bot_id" in session:
        return jsonify({"resp": "A bot must be selected"})

    if not get_bot(session["bot_id"]):
        return jsonify({"resp": ""})

    return jsonify({"resp": server.interface.ssh_exe(cmd)})


@app.route("/get-bot-info", methods=["POST"])

3 Source : micro.py
with MIT License
from Bitwise-01

    def create(self):
        if not 'link' in request.form:
            return jsonify({ 'resp': '' })

        link_url = request.form['link']
        link_url = self.parser_url(link_url)

        if not link_url:
            return jsonify({ 'resp': '' })

        if self.database.link_url_exists(link_url):
            return jsonify({ 'resp': self.server_url + self.database.get_link_id(link_url) })
        
        link_id = self.get_link_id(link_url)
        return jsonify({ 'resp': self.server_url + link_id})       
        
    def start(self):        

3 Source : notebook.py
with MIT License
from Bitwise-01

def delete_topic():
    resp = {'resp': 'error-msg'}

    if not 'topic_id' in request.form:
        return jsonify(resp)

    user_id = session['user_id']
    topic_id = escape(request.form['topic_id'].strip())

    if not profile_db.topic_exists(user_id, topic_id):
        return jsonify(resp)

    profile_db.delete_topic(topic_id)

    resp['resp'] = 'success-msg'
    return jsonify(resp)

# note
@app.route('/createnote', methods=['POST'])

3 Source : notebook.py
with MIT License
from Bitwise-01

def getnotes():
    resp = {'notes': []}

    if not 'topic_id' in request.form:
        return jsonify(resp)

    topic_id = escape(request.form['topic_id'].strip())

    if not len(topic_id):
        return jsonify(resp)

    resp['notes'] = get_notes(topic_id)
    return jsonify(resp)


@app.route('/note', methods=['GET'])

3 Source : notebook.py
with MIT License
from Bitwise-01

def logout_user():
    resp = {'resp': 'error'}

    if not 'user_id' in request.form:
        return jsonify(resp)

    user_id = escape(request.form['user_id'])

    if not account_db.user_id_exists(user_id):
        return jsonify(resp)

    resp['resp'] = 'success'
    account_db.logout(user_id)
    return jsonify(resp)


@app.route('/delete_user', methods=['POST'])

3 Source : notebook.py
with MIT License
from Bitwise-01

def delete_user():
    resp = {'resp': 'error'}

    if not 'user_id' in request.form:
        return jsonify(resp)

    user_id = escape(request.form['user_id'])

    if not account_db.user_id_exists(user_id):
        return jsonify(resp)

    if delete_usr(user_id):
        resp['resp'] = 'success'

    return jsonify(resp)


@app.route('/')

3 Source : routes.py
with MIT License
from bjorns

def begin_login():
    saml_request = flask.request.form['SAMLRequest']
    req = parse_request(saml_request)

    logging.info("Storing request %s", req.id)
    open_saml_requests[req.id] = req

    response = flask.make_response(flask.redirect("/saml/login", code=302))
    response.set_cookie('mockidp_request_id', value=req.id)
    return response


@app.route('/saml', methods=['GET'])

3 Source : app.py
with Apache License 2.0
from BlackIQ

def money():
     money = str(request.form['money'])
     all = 7
     person = money / all
     unit1 = person * 3
     unit2 = person * 4

     return "Unit 1 Must Pay :" , unit1
     return "Unit 2 Must Pay :" , unit2


if __name__ == "__main__":

3 Source : main.py
with MIT License
from Blockchain-Simplified

def create():
    # print("here")
    content = request.form
    print(content)
    rr = requests.post(URL + BASE_API + '/createUser', json=content)
    print(rr.json())
    return render_template('create.html')

@app.route('/join', methods=['POST'])

3 Source : main.py
with MIT License
from Blockchain-Simplified

def join():
    content = request.form
    rr = requests.post(URL + BASE_API + '/createUser', json=content)
    print(rr.json())
    
    return render_template('join.html')

@app.route(BASE_API + '/check', methods=['GET'])

3 Source : orders.py
with MIT License
from Blockstream

    def get(self, uuid):
        success, order_or_error = order_helpers.get_and_authenticate_order(
            uuid, request.form, request.args)
        if not success:
            return order_or_error
        order = order_or_error
        return order_schema.dump(order)

    def delete(self, uuid):

3 Source : start_web.py
with MIT License
from BnademOverflow

def open_url():
    url = request.form["id"]
    ses.session.get(url)
    return json.dumps({"status": True})


@app.route("/function/unfriend")

See More Examples