flask#HTTPBasicAuth

https://flask-httpauth.readthedocs.io/en/latest/

Flask FrameworkのHttp認証用

from flask import Flask,render_template
from flask_httpauth import HTTPBasicAuth
import sqlite3

app=Flask(__name__)
auth=HTTPBasicAuth()

users={
	"root":"root",
	"oper":"1234"
}

@auth.get_password
def get_pw(username):
	if username in users:
		return users.get(username)
	return None

@app.route("/")
@auth.login_required
def index():
	return "Hello!"+auth.username

if __name__=='__main__':
	app.run(port=5001)
Footer_Basic

Please Support some devices for my blog

Amazon Gift List

Find ME

Twitter:@3threes2
Email:soup01threes*gmail.com (* to @)
YoutubeChannel:https://www.youtube.com/channel/UCQ3CHGAIXZAbeOC_9mjQiWQ

シェアする

  • このエントリーをはてなブックマークに追加

フォローする