예제 #1
0
def add_user():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    from my_message.MyUser import create_random_user
    create_random_user().save()
    return jsonify({"Status": "Success"})
예제 #2
0
def hello_world():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    from my_message.MyMessage import create_random_message
    create_random_message().save()
    return render_template("pages/add.html")
예제 #3
0
def get_first_message():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    result = MyMessage.query.first()
    if result is None:
        return jsonify({"error": "There is no message"})
    return jsonify(result.serialize)
예제 #4
0
def get_all_users():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    results = MyUser.query.all()
    if results is None:
        return jsonify({"error": "There is no user"})
    all_users = [user.serialize for user in results]
    return jsonify(all_users)
예제 #5
0
def get_messages():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    results = MyMessage.query.all()
    if results is None:
        return jsonify({"error": "There is no message"})
    all_messages = [message.serialize for message in results]
    return jsonify(all_messages)
예제 #6
0
def display_visitors():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    results = MyVisitor.query.all()
    if results is None:
        return jsonify({"error": "There is no visitor"})
    all_visitors = [visitor.serialize for visitor in results]
    from flask import render_template
    return render_template("pages/visitors.html", visitors=results)
예제 #7
0
def clear():
    pw_hash = bcrypt.generate_password_hash('hunter2').decode('utf - 8')
    print(pw_hash)
    try:
        search_word = request.args.get('key', '')
        if bcrypt.check_password_hash(pw_hash, search_word):
            shared.db.drop_all()
            shared.db.create_all()
            from my_message.MyVisitor import save_visitor
            save_visitor(this_request=request)
            return jsonify({"status": "success"})
        return jsonify({"status": "unauthorized"})
    except KeyError:
        return jsonify({"status": "failed"})
예제 #8
0
def sitemap():
    """Generate sitemap.xml. Makes a list of urls and date modified."""
    from my_message.MyVisitor import save_visitor
    save_visitor(this_request=request)
    pages = []
    ten_days_ago = (datetime.now() - timedelta(days=10)).date().isoformat()
    # static pages
    for rule in app.url_map.iter_rules():
        if "GET" in rule.methods and len(rule.arguments) == 0:
            pages.append(
                [f"http://northdakota.servehttp.com{rule.rule}", ten_days_ago])
    sitemap_xml = render_template('pages/sitemap.xml', pages=pages)
    response = make_response(sitemap_xml)
    response.headers["Content-Type"] = "application/xml"
    return response
예제 #9
0
def get_home():
    from my_message.MyVisitor import save_visitor
    save_visitor(this_request=request)
    return render_template('pages/index.html')
예제 #10
0
def add_message():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
예제 #11
0
def ask_add_message():
    from my_message.MyVisitor import save_visitor
    from flask import request
    save_visitor(this_request=request)
    return render_template("pages/add_message.html")