What is netloc means..?












1















I'm learning to make login function with Flask-login, and I'm facing with this code in my tutorial that I'm following:



@app.route('/login', methods = ['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('index'))
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user is None or not user.check_password(form.password.data):
flash('Invalid username or password')
return redirect(url_for('login'))
login_user(user, remember=form.remember_me.data)
next_page = request.args.get('next')
if not next_page or url_parse(next_page).netloc != '': # what is it means in this line..?
next_page = url_for('index')
return redirect(next_page)
return render_template('login.html', title='Sign In', form=form)


But I'm not sure what's the code above that I commented means..?, especially in netloc word, what is that..?, I know that is stand for network locality, but what is the purpose on that line..?










share|improve this question




















  • 2





    Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

    – Paul Rooney
    Jan 1 at 2:59
















1















I'm learning to make login function with Flask-login, and I'm facing with this code in my tutorial that I'm following:



@app.route('/login', methods = ['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('index'))
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user is None or not user.check_password(form.password.data):
flash('Invalid username or password')
return redirect(url_for('login'))
login_user(user, remember=form.remember_me.data)
next_page = request.args.get('next')
if not next_page or url_parse(next_page).netloc != '': # what is it means in this line..?
next_page = url_for('index')
return redirect(next_page)
return render_template('login.html', title='Sign In', form=form)


But I'm not sure what's the code above that I commented means..?, especially in netloc word, what is that..?, I know that is stand for network locality, but what is the purpose on that line..?










share|improve this question




















  • 2





    Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

    – Paul Rooney
    Jan 1 at 2:59














1












1








1








I'm learning to make login function with Flask-login, and I'm facing with this code in my tutorial that I'm following:



@app.route('/login', methods = ['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('index'))
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user is None or not user.check_password(form.password.data):
flash('Invalid username or password')
return redirect(url_for('login'))
login_user(user, remember=form.remember_me.data)
next_page = request.args.get('next')
if not next_page or url_parse(next_page).netloc != '': # what is it means in this line..?
next_page = url_for('index')
return redirect(next_page)
return render_template('login.html', title='Sign In', form=form)


But I'm not sure what's the code above that I commented means..?, especially in netloc word, what is that..?, I know that is stand for network locality, but what is the purpose on that line..?










share|improve this question
















I'm learning to make login function with Flask-login, and I'm facing with this code in my tutorial that I'm following:



@app.route('/login', methods = ['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('index'))
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user is None or not user.check_password(form.password.data):
flash('Invalid username or password')
return redirect(url_for('login'))
login_user(user, remember=form.remember_me.data)
next_page = request.args.get('next')
if not next_page or url_parse(next_page).netloc != '': # what is it means in this line..?
next_page = url_for('index')
return redirect(next_page)
return render_template('login.html', title='Sign In', form=form)


But I'm not sure what's the code above that I commented means..?, especially in netloc word, what is that..?, I know that is stand for network locality, but what is the purpose on that line..?







python networking flask flask-login






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 14 at 3:47







user10873885

















asked Jan 1 at 2:30









Harvest 1018Harvest 1018

971115




971115








  • 2





    Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

    – Paul Rooney
    Jan 1 at 2:59














  • 2





    Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

    – Paul Rooney
    Jan 1 at 2:59








2




2





Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

– Paul Rooney
Jan 1 at 2:59





Although the function you are calling is from werkzeug. You can probably look to the standard library for the definition of netloc. See urllib.parse.urlparse. netloc is the name of the server (ip address or host name).

– Paul Rooney
Jan 1 at 2:59












1 Answer
1






active

oldest

votes


















3














From RFC 1808, Section 2.1, every URL should follow a specific format:



<scheme>://<netloc>/<path>;<params>?<query>#<fragment>


The netloc is what the first level domain (FLD) represents, which comes before the path, and after the scheme. For example you have the following URL:



http://www.example.com/index?search=src


Here, www.example.com is your netloc, while index is the path, search is the query parameter, and src is the value being passed along the parameter search.



Now coming to your code, the if statement checks whether or not the next_page exists and whether the next_page has a netloc so that the user could be redirected to index (default) page of your site.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992694%2fwhat-is-netloc-means%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    From RFC 1808, Section 2.1, every URL should follow a specific format:



    <scheme>://<netloc>/<path>;<params>?<query>#<fragment>


    The netloc is what the first level domain (FLD) represents, which comes before the path, and after the scheme. For example you have the following URL:



    http://www.example.com/index?search=src


    Here, www.example.com is your netloc, while index is the path, search is the query parameter, and src is the value being passed along the parameter search.



    Now coming to your code, the if statement checks whether or not the next_page exists and whether the next_page has a netloc so that the user could be redirected to index (default) page of your site.






    share|improve this answer






























      3














      From RFC 1808, Section 2.1, every URL should follow a specific format:



      <scheme>://<netloc>/<path>;<params>?<query>#<fragment>


      The netloc is what the first level domain (FLD) represents, which comes before the path, and after the scheme. For example you have the following URL:



      http://www.example.com/index?search=src


      Here, www.example.com is your netloc, while index is the path, search is the query parameter, and src is the value being passed along the parameter search.



      Now coming to your code, the if statement checks whether or not the next_page exists and whether the next_page has a netloc so that the user could be redirected to index (default) page of your site.






      share|improve this answer




























        3












        3








        3







        From RFC 1808, Section 2.1, every URL should follow a specific format:



        <scheme>://<netloc>/<path>;<params>?<query>#<fragment>


        The netloc is what the first level domain (FLD) represents, which comes before the path, and after the scheme. For example you have the following URL:



        http://www.example.com/index?search=src


        Here, www.example.com is your netloc, while index is the path, search is the query parameter, and src is the value being passed along the parameter search.



        Now coming to your code, the if statement checks whether or not the next_page exists and whether the next_page has a netloc so that the user could be redirected to index (default) page of your site.






        share|improve this answer















        From RFC 1808, Section 2.1, every URL should follow a specific format:



        <scheme>://<netloc>/<path>;<params>?<query>#<fragment>


        The netloc is what the first level domain (FLD) represents, which comes before the path, and after the scheme. For example you have the following URL:



        http://www.example.com/index?search=src


        Here, www.example.com is your netloc, while index is the path, search is the query parameter, and src is the value being passed along the parameter search.



        Now coming to your code, the if statement checks whether or not the next_page exists and whether the next_page has a netloc so that the user could be redirected to index (default) page of your site.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 12 at 7:13

























        answered Jan 1 at 4:37









        Infected DrakeInfected Drake

        1




        1
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992694%2fwhat-is-netloc-means%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith