Vue + Flask implements simple logon verification jump sample code, vueflask

Source: Internet
Author: User

Vue + Flask implements simple logon verification jump sample code, vueflask

This article introduces Vue + Flask for simple login verification jump and shares it with you, as follows:

File Location:

Login.html

<! DOCTYPE html> 

Index.html

<!DOCTYPE html>

Login. py

#-*-Coding: UTF-8-*-from flask import Flask, request, session, redirect, url_for, render_template, make_response, jsonifyapp = Flask (_ name _) @ app. route ('/login', methods = ('get', 'post') def login (): if request. method = 'post': session ['username'] = request. json. get ('username') session ['Password'] = request. json. get ('Password') # log on to the index page and return jsonify ({'code': 200, 'Token': "123456 "}) # Logon Failed. Go to the current logon page and return render_template('login.html ') @ app. route ('/Index') def index (): # if both the user name and password exist, go to the index page. if the logon succeeds, if 'username' in session and 'Password' in session: return render_template('index.html ') # Otherwise, go to the login page return redirect (url_for ('login') @ app. route ('/logout') def logout (): session. pop ('username', None) session. pop ('Password', None) return redirect (url_for ('login') # set the secret Key. keep this really secret: app. secret_key = 'a0zr98j/3yX R ~ XHH! JmN] LWX /,? RT 'if _ name _ = '_ main _': app. run (debug = True)

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.