使用HTTPBasicAuth向网站添加密码

时间:2017-06-20 19:22:50

标签: python flask

所以我正在尝试为此应用程序添加密码:https://github.com/RocketMap/RocketMap。过了一段时间后,我发现主要网站呈现的文件(渲染模板)位于/pogo/app.py,所以我尝试添加所有内容,虽然我遇到app.Flask有问题,因为应用程序本身没有启动app.py但是通过runserver.py。有人能帮我吗? :d 这是我更改过的代码(我剪切了不相关的部分,这里是原始代码:https://github.com/RocketMap/RocketMap/blob/develop/pogom/app.py):

  import flask
  from flask import Flask
  from flask_httpauth import HTTPBasicAuth



app = flask.Flask(__name__)
auth = HTTPBasicAuth()
users = {
"john": "hello",
"susan": "bye"
}





class Pogom(Flask):

def __init__(self, import_name, **kwargs):
    super(Pogom, self).__init__(import_name, **kwargs)
    compress.init_app(self)

    args = get_args()
    self.route("/", methods=['POST','GET'])(self.fullmap)
@auth.get_password
def get_pw(username):
    if username in users:
        return users.get(username)
    return None
@app.route('/')
@auth.login_required
def fullmap(self):
    self.heartbeat[0] = now()
    args = get_args()

0 个答案:

没有答案