BASIC authentication with Python bottle

BASIC authentication can be applied by using bottle.auth_basic as a decorator. Requires v0.12 or higher.

hello.py


# -*- coding: utf-8 -*-
import bottle


#BASIC authentication username and password
USERNAME = "user"
PASSWORD = "pass"


def check(username, password):
    u"""
Check BASIC authentication username and password
    @bottle.auth_basic(check)Apply in
    """
    return username == USERNAME and password == PASSWORD


@bottle.route("/hello")
@bottle.auth_basic(check)
def hello():
    return "hello"
    

if __name__ == '__main__':
    bottle.run(host='localhost', port=8080, debug=True)

Run

$ python hello.py

Recommended Posts

BASIC authentication with Python bottle
Basic authentication with an encrypted password (.htpasswd) in bottle with python
Achieve Basic Authentication with CloudFront Lambda @ Edge with Python 3.8
Send HTTP with Basic authentication header in Python
[Python] Using OpenCV with Python (Basic)
[Python] [SQLite3] Operate SQLite with Python (Basic)
Implemented file download with Python + Bottle
Scraping with Selenium in Python (Basic)
[Python] Use Basic/Digest authentication with Flask
Basic authentication and Digest authentication with Flask
1. Statistics learned with Python 1-1. Basic statistics (Pandas)
Basic study of OpenCV with Python
FizzBuzz with Python3
Scraping with Python
Getting Started with python3 # 1 Learn Basic Knowledge
RF Python Basic_01
Scraping with Python
Passwordless authentication with RDS and IAM (Python)
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
Basic Python writing
Setting up Basic authentication using Python @Lambda
python starts with ()
Learn Python! Comparison with Java (basic function)
[Python] A quick web application with Bottle!
with syntax (Python)
Python3 basic grammar
Bingo with python
Zundokokiyoshi with python
RF Python Basic_02
Python Https Authentication
Excel with Python
Flask Basic authentication
Microcomputer with Python
Cast with python
Addictive point when going through http proxy with basic authentication in python
Explosive speed with Python (Bottle)! Web API development
Flow to complete Slack authentication with Flask (Python)
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Python basic course (12 functions)
Python I'm also basic
Try scraping with Python.
Python Basic Course (7 Dictionary)
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Python basic course (2 Python installation)
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python