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"})
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")
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)
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)
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)
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)
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"})
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
def get_home(): from my_message.MyVisitor import save_visitor save_visitor(this_request=request) return render_template('pages/index.html')
def add_message(): from my_message.MyVisitor import save_visitor from flask import request save_visitor(this_request=request)
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")