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.