Python Forum
How can users store data temporarily in flask app?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can users store data temporarily in flask app?
#1
Hi
Im wondering how users in my app can store data temporarily?

Right now im using lists who shows some data the user inputs. It works kind off when the app is used locally but its starts not to show every thing etc in the lists when the app is used on heroku. And i realized that i cant use lists like that if multiple users us the app. Do any one have any ideas how i can do it?
Reply
#2
What kind of data? What does temporarily mean?
How do you need to access it? Web apps often use a database for storing data. Heroku at least gives you access to Postgres, but others may be available.
Reply
#3
(Mar-21-2022, 12:43 PM)ndc85430 Wrote: What kind of data? What does temporarily mean?
How do you need to access it? Web apps often use a database for storing data. Heroku at least gives you access to Postgres, but others may be available.

Its just small text sequences my app generat. With temporary i mean that the data should be removed lets say after one hour or logout. And it should only be visible for the user who generated it. Yes i know heroku use postgres i use it for user accounts.

The data can look like this

W3.1
W3.2
W3.3
W3.sc
Reply
#4
Could you just store the data in memory then? Is there a downside to doing that?
Reply
#5
(Mar-21-2022, 05:42 PM)ndc85430 Wrote: Could you just store the data in memory then? Is there a downside to doing that?

Thats what i do now. I use list for it. But some times not all input gets added to the list and when i spam refresh in the browser it shows the missing inputs but not the first inputs in the table. I know its strange. But this does not happen when i run the app locally on my computer. So i have no idea what to do to get it to work on heroku.
Reply
#6
You haven't shown any code, so we'd have to guess at what the problem could be, wouldn't we?
Reply
#7
(Mar-21-2022, 06:07 PM)ndc85430 Wrote: You haven't shown any code, so we'd have to guess at what the problem could be, wouldn't we?

No its just lots of code so i will try to minimize it

my list that i use to store the data.they are global
sample_data1=[]
sample_data2=[]
sample_data3=[]
this is some of the code that generate the data and adds it to the lists
for parts in range(partfran-1, parttill):
	print('{}{}{}{}{}\n'.format(name, bindning, parts+1, bindning,  parts+1))
	sample_data1.append('{}{}{}{}{}\n'.format(name, bindning, parts+1, bindning,  parts+1))
sample_data2.append('{}\n'.format(name))  


this code shows whats in the sample_data2 list.
@app.route("/slutsteg1", methods=["GET", "POST"])
@roles_required(['admin', 'user'])
def sistasteg1():
    mylist = sample_data2
    my_list = []
    
    for (i, item) in enumerate(mylist, start=1):
         my_list.append({"ID":i, "Märkning":item})

    return render_template("slutsteg1.html",my_list=my_list)  


this shows whats in my_list list in a table
Quote: {% for item in my_list %}
<tr>
<td style="text-align:center">{{ item.ID }}</td>
<td style="text-align:center">{{ item.Märkning }}</td>
</tr>
{% endfor %}
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How and where to store a data for path tree? zayacEBN 1 1,902 Aug-21-2020, 10:14 PM
Last Post: Larz60+
  Extract json-ld schema markup data and store in MongoDB Nuwan16 0 2,413 Apr-05-2020, 04:06 PM
Last Post: Nuwan16
  how to store data from the soup in the loop? zarize 1 1,637 Mar-02-2020, 04:17 PM
Last Post: Larz60+
  how to save the data from MySQL to CSV in Flask farah97 4 2,881 Jan-03-2020, 03:02 AM
Last Post: farah97
  Using flask to add data to sqlite3 table with PRIMARY KEY catafest 1 3,703 Sep-09-2019, 07:00 AM
Last Post: buran
  Flask data with dynamic updates from panadas parthi1705 0 2,064 Jun-19-2019, 09:59 AM
Last Post: parthi1705
  flask requests display data from api on webpage with javacript pascale 0 2,742 Oct-25-2018, 08:30 PM
Last Post: pascale
  Paginate json data in flask or jinja2 soli1994 1 8,249 Jun-28-2018, 06:00 PM
Last Post: gontajones
  How to perform predictions on a data in csv file using Flask? manjusavanth 0 4,489 May-23-2018, 09:03 AM
Last Post: manjusavanth
  Insert data to SQL through pymysql and flask iainstott 3 7,657 Oct-24-2017, 03:04 PM
Last Post: iainstott

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020