Flask

Clean server-side session files - Flask-Session using filesystem

◇◆丶佛笑我妖孽 提交于 2020-07-17 08:54:33
问题 I chose to use a server-side session management with Flask using Flask-Session. I store the data using filesystem and as expected, these files are stored under a /flask_session folder in my config directory. Here is how I set this up in my __init__.py # __init__.py from flask_session import Session [...] app.config['SESSION_TYPE'] = 'filesystem' app.config['SECRET_KEY'] = config.SECRET_KEY sess = Session() sess.init_app(app) As expected, session files generated & stored under /flask_session ▾

How to display flashing message without reloading the page in Flask?

房东的猫 提交于 2020-07-17 07:14:14
问题 I'm working on a web application using Flask in Python. I have small function in my application that calculates some values in the background and displays the result on the web page via a flashing message. Everything is displaying and working fine but it requires page reloading to get the flashing message. I want to display messages without reloading page. I heard that I can do that with js, but I'm not familiar with js. If you have any ideas or suggestion I would appreciate. There is my code

Flask-RESTful vs Flask-RESTplus

时间秒杀一切 提交于 2020-07-16 17:02:33
问题 Other than the ability to automatically generate an interactive documentation for our API using Swagger UI, are there any real advantages of using Flask-RESTplus over Flask-RESTful? 回答1: update When reading this accepted answer, consider that there is Flask-RESTX which is a fork of Flask-RESTPlus that is maintained, as an alternative option. I am aware of the fact that this answer is probably too late, but it still might be helpful in the future. According to https://github.com/noirbizarre

Get the value of element that was clicked on then use flask to delete that value from your sqlite3 database?

不想你离开。 提交于 2020-07-16 08:27:10
问题 I'm really stumped on this. I can add an item to my database by using a form just fine but how do I delete from it? I like to delete it either by clicking on it or clicking on it and then clicking the "remove" button. Flask @app.route('/', methods=["GET", "POST"]) def home(): db = get_db() if request.method == "GET": return render_template("index.html") else: item = request.form['item'] session['item'] = item quantity = request.form['quantity'] session['quantity'] = quantity db.execute(

Get the value of element that was clicked on then use flask to delete that value from your sqlite3 database?

寵の児 提交于 2020-07-16 08:26:39
问题 I'm really stumped on this. I can add an item to my database by using a form just fine but how do I delete from it? I like to delete it either by clicking on it or clicking on it and then clicking the "remove" button. Flask @app.route('/', methods=["GET", "POST"]) def home(): db = get_db() if request.method == "GET": return render_template("index.html") else: item = request.form['item'] session['item'] = item quantity = request.form['quantity'] session['quantity'] = quantity db.execute(

Get the value of element that was clicked on then use flask to delete that value from your sqlite3 database?

你离开我真会死。 提交于 2020-07-16 08:25:06
问题 I'm really stumped on this. I can add an item to my database by using a form just fine but how do I delete from it? I like to delete it either by clicking on it or clicking on it and then clicking the "remove" button. Flask @app.route('/', methods=["GET", "POST"]) def home(): db = get_db() if request.method == "GET": return render_template("index.html") else: item = request.form['item'] session['item'] = item quantity = request.form['quantity'] session['quantity'] = quantity db.execute(

TypeError: get_bind() got an unexpected keyword argument

旧巷老猫 提交于 2020-07-16 08:11:29
问题 I am trying to use a database in flask using from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker In it I am created a basic login page and a register page and when I try to use html code: <form action="/login" method="post"> <input autocomplete="off" autofocus name="username" placeholder="Username" type="text"> <input class="form-control" name="password" placeholder="Password" type="password"> <button class="btn btn-primary" type="submit">Log In<

TypeError: get_bind() got an unexpected keyword argument

五迷三道 提交于 2020-07-16 08:10:29
问题 I am trying to use a database in flask using from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker In it I am created a basic login page and a register page and when I try to use html code: <form action="/login" method="post"> <input autocomplete="off" autofocus name="username" placeholder="Username" type="text"> <input class="form-control" name="password" placeholder="Password" type="password"> <button class="btn btn-primary" type="submit">Log In<

Flask sqlalchemy.exc.OperationalError: (OperationalError) no such table when trying to update database with SQLAlchemy

可紊 提交于 2020-07-16 05:52:22
问题 I'm new to Flask, and having some issues setting up a very basic Flask app. Right now, I'm trying to get the user to submit a form on the homepage and then save that form to a SQL database. However, when the user submits the form, I get the following error sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: contact [SQL: 'INSERT INTO contact (name, email) VALUES (?, ?)'] [parameters: ('aaa', 'aaa')] (Background on this error at: http://sqlalche.me/e/e3q8) Relevant code

Looking for inverse of url_for in Flask

梦想与她 提交于 2020-07-15 03:03:44
问题 I am using Flask and Flask-RESTful to build a REST API. Within this API some of my resources contain url relations to other resources. When performing POST requests to these resources I am finding that I am needing the inverse of Flask's url_for() function to parse the incoming url. For example, a POST to https://www.example.com/buildings may contain the following json: { "address": "123 Lyall St", ... "owner": { "href": "https://www.example.com/users/21414512" }, "tenant": { "href": "https:/