dimanche 26 février 2017

how a flask-python script calls another flask-python script

I'm new in flask-py2neo-pyhon-neo4j so I need some help I have the following issue. My main .py that runs/executes is views.py I have another py script where I have the submission of some form_data.html>to be more clear views.py --calls-->app.py--calls--> form_action.html & form_submit.html how can i achieve this sequence?? the flask-python code: views.py

@app.route('/vital', methods=['GET','POST'])
def vital():
#    username = session.get('username')

    name=request.form['pname']
    sfx=request.form['psfx']
    midname=request.form['pmidname']
    bsurname=request.form['pbsurname']

#    if not name:
#        flash('You must give your post a name.')
#    elif not sfx:
#        flash('You must give your post a suffix.')
#    elif not midname:
#        flash('You must give your post a midname.')
#    elif not bsurname:
#        flash('You must give your post a bsurname.')
#    else:
#        User(session['username']).vital(name, sfx, midname, bsurname)

    return render_template('form_action.html', username=username, sfx=sfx, midname=midname, bsurname=bsurname)

app.py

from flask import Flask, render_template, request, url_for
app = Flask(__name__)

@app.route('/')
def form():
    return render_template('form_submit.html')

@app.route('/hello/', methods=['POST'])
def hello():
    name=request.form['pname']
    sfx=request.form['psfx']
    midname=request.form['pmidname']
    bsurname=request.form['pbsurname']
    return render_template('form_action.html', name=name, sfx=sfx, midname=midname, bsurname=bsurname)

if __name__ == '__main__':
    app.run()
    send_data()

form_action.html

 <html>
    <head>
        <title>Person</title>
    <link rel=stylesheet type=text/css href="">    
    </head>
    <body>
        <div id="container">
            <div class="title">
                <h1>Person's Vital Information</h1>
            </div>
            <div id="content">
                Tell us  about <strong></strong> !
            </div>
            <div class="title">
                <h1>Flask code</h1>
            </div>
                <code><pre>
@app.route('/hello/', methods=['POST'])
def hello():
    name=request.form['pname']
    sfx=request.form['psfx']
    midname=request.form['pmidname']
    bsurname=request.form['pbsurname']

    return render_template('form_action.html',  name=name, sfx=sfx,  midname=midname, bsurname=bsurname)
                </pre></code>   
            </div>
        </div>
    </body>
</html>

form_submit.html

<html>
    <head>
        <title>Person</title>
        <link rel=stylesheet type=text/css href="">    
    </head>
    <body>
        <div id="container">
            <div class="title">
                <h1>Person's Vital Information</h1>
            </div>
            <div id="content">
                <form method="post" action="">
        <label for="pname">Name:</label>
                <input type="text" name="pname" /><br />
                <label for="psfx">Suffix: </label>
        <input type="text" name="psfx" /><br />
        <label for="pmidname">Middle Name: </label>
        <input type="text" name="pmidname" /><br />
        <label for="pbsurname">Birth Surname: </label>
        <input type="text" name="pbsurname" /><br />

        <input type="submit" />
                </form>
            </div>
            <div class="title">
                <h1>Flask code</h1>
            </div>
                <code><pre> 
@app.route('/')
def form():
    return render_template('form_submit.html')
                </pre></code>   
            </div>
        </div>
    </body>
</html>




Aucun commentaire:

Enregistrer un commentaire