Questions tagged [flask]

Flask, a nimble Python framework, empowers the development of web applications with its agility and versatility.

Python script to read and write JSON files on the Google Cloud Storage platform

Recently, I came across a fascinating scenario involving a JSON file stored in a Cloud Storage bucket. Is there an effective approach to read and potentially modify the data within using Python? @app.route("/myform/", methods=('GET', 'POST')) def myform() ...

Failure to upload file using AngularJS

Below is the code snippet for file uploading: Here is the HTML code used to select and upload the file: <form ng-click="addImportFile()" enctype="multipart/form-data"> <label for="importfile">Import Time Events File:</label><br&g ...

What is the most efficient method for transferring Flask variables to Vue?

I am currently developing a visualization application using a flask server and vue.js for the front end. Other discussions on this topic explore how to avoid conflicts between vue.js and flask variable syntax, as shown here. In my scenario, I'm inte ...

Adjust or alter relationship attributes in py2neo

How can I update a relationship property in py2neo or cypher after it has been initially set? In my inventory tracking system, when an item is checked out, the "status" property in the relationship is set to "True". However, I'd like to change this propert ...

Execute the task immediately after receiving the JSON response

Whenever the mobile app requests specific data, I must execute a task. The user may not need the task completed immediately, but within the next 2 minutes. Being relatively new to Python and web development, I am unsure of how to achieve this. I prefer n ...

Perform a Fetch API request for every element in a Jinja2 loop

I've hit a roadblock with my personal project involving making Fetch API calls to retrieve the audio source for a list of HTML audio tags. When I trigger the fetch call by clicking on a track, it always calls /play_track/1/ and adds the audio player only ...

The Zip file generated in memory is experiencing corruption

I'm encountering an issue while attempting to serve a zip file generated in memory by Flask to a JavaScript front-end. However, the downloaded file appears corrupted and I am unsure of what mistake I may be making. @app.route('/route') def test_zip(): ...

A guide on incorporating JSX file rendering in Flask

I am currently working on integrating React Contact form with MYSQL Workbench using Flask. I have set up the database initialization and model using SQLAlchemy, but I am encountering an issue with the render_template function. Is it possible to render th ...

Check out the latest enhancements to React and Flask Fullstack right from your web browser

Recently, I ventured into the world of React and Flask development by following a tutorial found at this link. After completing the example fullstack website project, I realized that my code mirrored exactly what was provided by the author on their Github ...

Has Flask already sanitized the request data?

Is it necessary to ensure proper handling of user-generated data (such as cookie values, variable segments in URLs, and query arguments), or can Flask sanitize and escape input automatically before passing it to a function like test(input_data)? ...

Fetching data in React using AJAX

I am in the process of developing a React Component that will display data retrieved from an AJAX call. Here's my scenario - I have a Jinja Flask back end hosted on AWS API Gateway, which requires custom headers and the Authorization header to serve HTML a ...

The variable 'React' has been declared but appears to be unused, what might be causing this problem?

Currently, I am developing a contact application using Python with React. While utilizing Vite and Flask for development, I encountered an error stating that 'React' is defined but never used. Below is a snippet of my code structure: This section represen ...

Troubleshooting error code 400 in Flask when processing request.json

I'm currently facing an issue with properly formatting a response using Flask.requests.json @app.route("/slack/post", methods=["POST"]) def post_response_to_slack(): try: body = request.json The output when using request.data is: b'{"phone":" ...

"Encountering HTTP 400 Bad Request Error When Using Flask and Ajax for Post Requests

I'm currently developing a small Flask-based website and I want to use Ajax to send data from the client to the server. So far, I've only used Ajax requests to fetch data from the server, but this time I want to submit data via a POST request. On the Flas ...

Combining Flask with npm: A Comprehensive Guide

I have a unique flask application that initiates with python3 app.py running on localhost:5000 Moreover, there is another distinct nodejs program that kicks off with npm run start which operates on localhost:3000 The challenge that lies ahead for m ...

Encountering a 503 error after deploying Flask on CloudRun

I encountered an issue while trying to deploy a simple Flask app that utilizes Google Bucket. Upon deployment, I kept getting error 503 - Service Unavailable. I'm unsure if I missed something crucial or what exactly I might be doing wrong. Any assistance ...

The information stored in Flask sessions is not retained across different sessions

Currently, I am constructing a website using React alongside Python with Flask. An issue has arisen where the session data is being lost between sessions and the cause remains unknown. Within the app.py file in Python, you can find the following app confi ...

Is there a way to send all the results of a Flask database query to a template in a way that jQuery can also access

I am currently exploring how to retrieve all data passed to a template from a jQuery function by accessing Flask's DB query. I have a database table with customer names and phone numbers, which I pass to the template using Flask's view method "db.query.all ...

How to Render a Template in Flask and Capture Request Headers Data?

I am currently working on a project in my Flask app where I need to store data retrieved from the request.headers. My goal is to display the index.html when the page loads, but I also want to extract the email of the user visiting so that I can utilize it ...

What is the best way to align the variables in this JavaScript file with the variables in Flask/Python?

I have a JavaScript file that enables dynamic drop-down menus (i.e. selecting one option affects the others). However, I hard-coded the starting variables in this file to HTML elements 'inverter_oem' and 'inverter_model_name'. Now, I need to reference diff ...

The Java to Python conversion of a POST request results in receiving a null response

As I embark on my journey with Python Flask, I have encountered a hurdle while coding using the requests and flask modules. My current project revolves around utilizing the web API provided by the Panther platform. The project initially demonstrated an ex ...

Using an HTML form to gather data, you can store the information in a SQL database using SQLAlchemy in a

Struggling to extract a list of values from an HTML form using Flask and store them in a database column. Attempted to use getlist() method but unsure about the correct way to implement it. Database: association_table = Table('association', Bas ...

Is there a way to showcase the outcome of a Python script on an HTML webpage?

Hey there, I'm a beginner to coding and I've been working on a little project to track the price of gold in a web application using Flask and Python. In my HTML code, I have a button that, when clicked, takes users to a new route where the gold price is d ...

Running Postgres on your own computer is a straightforward process that can

After reading the documentation for Postgres in relation to Flask I learned that in order to run Postgres, it is necessary to include the following code snippet: app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = postgresql://localh ...

SQLAlchemy reports module not callable

Below is the Python code that triggered an error: @app.route('/home/logedin/', methods=["get", "post"]) def verLogIn(): passW = request.form['pass'] email = request.form['email'] engine = create_engine('sqli ...

Stuck with the same icon even after a successful AJAX call

I am currently working on implementing a 'add to my list' function in my web app. The goal is to change the color of an icon when a user clicks on it, after sending the necessary data to the server. Despite successfully sending the data to the server with ...

Using Bloodhound with a JSON generated using Flask's jsonify function is a seamless process

Recently, I have been exploring the Bloodhound typeahead feature to implement database search functionality in my Flask application. I found a helpful guide on how to set this up at: Twiiter Typeahead Custom Templates - Getting Default Example Working $(d ...

Tips for seamlessly incorporating MongoMock with Pymongo-Flask

Looking to create unit tests for our mongo code using mongomock as the backend. However, facing a challenge with Flask-PyMongo which has a convenience class (find_one_or_404) added on top of the Collection class, complicating straight MongoMock substitut ...

What is the best way to properly handle closing database connections when executing Flask API calls within a cron job?

When the cronjob runs, it connects to various databases through different API calls using an admin session. I want to make sure that after each call, the connection is closed properly. While for a normal API call I can use before_request to open and after_ ...

Utilizing WSGI in conjunction with a Python/Flask application - A guide from HasGeek's Lastuser

Currently, I am in the process of setting up a lastuser OAuth server on my local machine. My plan is to configure Nginx with SSL (on port 443) and utilize the lastuser app as the WSGI server. If you want more details about the HasGeek lastuser project, ch ...

JS receiving a reference to an undefined variable from Flask

I referenced this helpful post on Stack Overflow to transfer data from Flask to a JS file. Flask: @app.route('/') def home(): content = "Hello" return render_template('index.html', content=content) HTML <head> ...

There seems to be a glitch with the Flask flash messaging feature, as

My Flask application includes login and register routes where I aim to display flash messages when username passwords are not matched. Specifically, this issue arises in my index and login routes: @app.route('/') @login_required def index(): return 'He ...

Using JQuery to create a button inside a Modal dialog box

My goal is to select a row within a Table that is located inside a Modal window, and then have a button ('newBtn') within that Modal window trigger a post request to the server with the selected id of the row. However, the issue I am encountering ...

"Upon receiving a Date with Time from Mui, the flask api is responding with the error message 'invalid date value

Hey, I am currently utilizing Mui's date picker in my frontend application <LocalizationProvider dateAdapter={AdapterDateFns}> <TimePicker name='timeValue' label="Time" ...

What is the best way to broadcast messages to multiple clients using Flask-SocketIO?

Currently, I am diving into the world of Flask-SocketIO with a simple chat application in mind. However, I've encountered an issue where messages are not being received by anyone except for the user in the browser. Here's the Python/Flask code sn ...

Use Python's request module to send a message to Telegram via API

I attempted to send a message to Telegram using Python while running the code on Heroku. I utilized the import request library for this task. The message was successfully sent, but I encountered an issue with Heroku: Traceback (most recent call last): 202 ...

jQuery mistakenly sends a GET request instead of a POST request

Has anyone encountered an issue where attempting to send a POST request to Flask using jQuery results in a GET request instead? This is a new problem for me, and I'm unsure why it's happening. jQuery system_data = { "system_name":"system_name ...

Python Debug Error: Unable to locate flask module

from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////mydatabase.db' db = SQLAlchemy(app) class User(db.Model): id = db.Column(db.Integer, primary_key=True) user ...

Flask SQL Alchemy attempting SET operation unnecessarily

Encountering a perplexing issue with SQL Alchemy. I have a table in SQL server dedicated to storing Sales data, structured as follows: CREATE TABLE Resale ( [address] VARCHAR(100) NOT NULL, [id] BIGINT NOT NULL, [price] INT NOT NULL, [start_date] D ...

Obtaining fresh data with Peewee and Flask only upon restarting

I'm encountering a peculiar issue with my Flask + Peewee application. I have a web app that inserts data into a MySQL database. My Flask app also connects to this database using Peewee. The problem arises when I insert data with the web app - subsequent ...

Building a personalized payment experience using Python Flask and Stripe Checkout

I'm attempting to set up a customized checkout integration with Stripe on my Flask web application and I've encountered some issues. After copying the code from the Stripe documentation (located at ) into the bottom of my HTML file, the Stripe checkout sc ...

What is the appropriate way to utilize `render_template` from Flask within Angular?

I'm facing an issue where I need to implement different routes for various Angular Material tabs. I have attempted to directly call Flask from the template, as demonstrated below, but unfortunately, I am unable to invoke render_template from Angular. As ...

Do we really need to use Flask-Marshmallow's init_app() function?

Upon reviewing the Flask-Marshmallow documentation, it states that Marshmallow.init_app() initializes the application with the extension. The code snippet linked in the documentation appears to play a significant role in managing SQLAlchemy sessions: ...

How can you give a block a unique name using a variable in Jinja2?

In the template "base.html" that I have, there is a set of ids called list_of_ids. The template contains a for loop that goes through each id in this list and outputs a specific block of content for each one. {% set list_of_ids = ['id1', 'id2', 'id3'] %} ...

How do I navigate to a different page in a Flask app after an ajax post depending on a condition detected in the view?

Within my flask application, I have a sales page where users can input information that is then saved to the database using an ajax post request. The twist is that there are only a limited number of consoles available for users to record their sales. If on ...

Encountering an error when sending data from a React application to a Flask server: Unhandled Promise Rejection - Unexpected < token in

Despite looking through various responses on this forum, I'm still encountering the same issue. My JSON is properly formatted and does not contain any HTML tags. I've tried using double quotes instead of single quotes for 'Key', but it's not resolving the ...

p5.js experiencing issue: Uncaught TypeError - Unable to access property 'transpose3x3' due to null value

I have a simple website built with Flask where I am running several p5.js sketch animations, and everything is working smoothly. However, when I try to add a new sketch that utilizes WEBGL, I encounter the following error: Uncaught TypeError: Cannot read p ...

Refine the pandas Dataframe with a filter on a JavaScript-enabled website

I recently inherited a large software project using Python/Flask on the backend and HTML/Javascript on the frontend. I'm now looking to add some interactivity to one of the websites. I have successfully passed a dataframe to the webpage and can display its ...

When the FLASK button is triggered, retrieve data from the FLASK and display it

This is a unique test where I will create a button to retrieve information from a MySQL database. However, it's important to first understand this concept. So here is my custom text within the Flask framework: @app.route('/pythonlogin/home', methods=['GET' ...

How can I nicely display a SQLAlchemy database with models and relationships in an organized manner?

Looking to visualize the structure of my database in a more comprehensive way. Using Flask-SQLAlchemy as an example, with various models and relationships sourced from SQLAlchemy Docs. class IDModel(db.Model): __abstract__ = True id = db.Column(db.Int ...

Send the data from a table to a Python method in Flask using AJAX

Recently, I picked up on flask and decided to create a small web tool for organizing data. The main page displays a table of list numbers and their respective descriptions. I managed to implement jQuery functionality that allows double clicking to select i ...

Showing information from Flask API utilizing Angular with underscores

I'm in the process of creating components from my Flask API. Upon accessing the route, I can view the data for the desired objects. However, upon attempting to display it on the front end through interpolation, I am only able to see certain properties (spe ...

When working in Flask, I am experiencing an issue where my CSS is not linking to my

I am new to coding with HTML, CSS, and Flask and I have encountered an issue where my CSS styling only partially affects my HTML file. Here is the HTML code snippet: <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...

Two applications installed on a single server, each running on its own port. The first application is unable to communicate with the second

I have two applications running on the same VPS (Ubuntu) and domain. The first is a Node.js app running on port 80, while the second is a Python (Flask) app running under Apache on port 3000. The Python app has a simple API with one endpoint /test. When I ...

Unable to establish a connection to the Flask webserver

Testing my code on Visual Studio 2017 with the file named test: from flask import Flask, request #import main Flask class and request object from test import app app = Flask(__name__) #create the Flask app @app.route('/query-example') def ...

Having difficulty retrieving POST request information from an HTML form using Flask

I have been experimenting with building a website back-end using the Python library Flask. However, I keep encountering a 405 - Method not allowed error whenever I attempt to retrieve form data from a POST request in a secure manner. Right now, after a use ...

The forecast button seems to be malfunctioning. Each time I attempt to click on it, a message pops up saying, "The server failed to comprehend the request sent by the browser (or proxy)."

Even though I provided all the necessary code, including the Flask app, predictionmodel.py, and HTML code, I am still encountering an error when running it locally after clicking submit. The browser (or proxy) sent a request that this server could not un ...

Organizing a Flask project for optimized workflow with Grunt

After purchasing an HTML/CSS/Js admin template built on the Bootstrap framework, I found that it met most of my MVP needs. My plan was to customize it slightly and then integrate my backend developed with Flask. Being relatively new to this field, I was i ...

Guide on redirecting to a specific Vue-app page using Flask

I am currently working on an application that includes a page that ends with '@' and provides meta information for the page without '@'. For example, if the page '/user/aabb' contains information about the user 'aabb', then the page '/user/aabb@' serves as ...

"Vibrant hues in a flask with interactive colorbox

I am currently using Jquery colorbox in conjunction with Flask. Upon the user clicking on an icon, a URL is submitted by the script to display a form within the colorbox. Once the user clicks the save button, the form is submitted and the colorbox is close ...

When using flask.jsonify, the output is wrapped in square brackets, as opposed to the usual curly

I'm currently facing an issue with my Flask and jsonify setup. When I try to output JSON, it's coming back in array format with square brackets instead of the expected JSON object with curly brackets. Does anyone have guidance on how to resolve ...

Flask does not accept user input directly from WTForms

I am currently working on developing an application using Flask with WTForms. Here is the setup in my controller.py file: @mod_private.route('/portfolio/', methods=['GET', 'POST']) @login_required def portfolio(): print "in portfolio" # This line is ...

Retrieve another resource from the Flask API

I have developed a basic Flask API that returns a list of strings. Here is the code: from flask import Flask, request from flask_restful import Resource, Api from json import dumps app = Flask(__name__) api = Api(app) class Product(Resource): def ge ...

Connect the CSS file in React index.html to the Flask backend

I am attempting to connect a CSS template that is serving static backend content through Flask with my React frontend. Here is the structure I am working with: client/ src/ components/ menu.jsx public/ ...

Problem with spawning Python when using VUE2, Electron, and Flask

After completing my first project using Vue, Electron, and Flask, I am encountering difficulties packaging it. While everything works perfectly with "npm run electron:serve," there seems to be an issue when running "npm run electron:build" as Flask is not ...

Converted my Flask code into a specialized software package, encountering a perplexing TemplotNotFound error

After reorganizing my Flask code into a Python package structure, I am facing an issue where none of the HTML templates can be found when I run the code. Let me outline the simplified structure of my current Flask package. The run.py file is responsible f ...

Retrieving table names while querying database in Python Flask

Recently, I made the switch from PHP to Flask after three years. I successfully connected to my local server and database, and managed to query data from it and display it on screen. However, when attempting to work on a small REST API project, I ran int ...

Tips for customizing WTForm fields with unique CSS classes

I've recently put together a basic form snippet: class PostForm(FlaskForm): # for publishing a new blog post title = StringField("Title", validators=[DataRequired()]) submit = SubmitField('Post') The structure of my HT ...

Error Message: The code is throwing an AttributeError because a boolean object does not contain the attribute '_sa_instance_state' when attempting to verify its presence in the database

Recently diving into Flask and SQLA, I am in the process of building a compact educational platform where individuals can explore US national parks (leveraging the National Park Service API). I aim to provide registered users with the capability to bookmar ...

Buildpack Python heroku is not supported by the Flask app

I am experiencing difficulties deploying my Flask application on Heroku. I have created a Procfile with the following content: web: gunicorn routes:app along with a requirements.txt file listing all the dependencies required: click==6.7 Flask==0.12 guni ...

Avoid the resetting of chosen value following a POST or submission

I am currently working on creating a "web dashboard" that requires a year_from parameter from an HTML form. Despite setting up my Flask backend to return data within this specified range, I am encountering a problem where every time I hit submit, the selec ...

The output from the Python and SQLite combination is accurate, however the HTML rendering is not displaying the data correctly

Retrieving data from a database using different methods can yield varied results. When the method is set to 'get', it returns all information, but when it's 'post', it only returns the searched item. Although the post method returns the correct value, HTML ...

The email confirmation feature in Flask-Security using Flask-Mail fails to send unless changes are made to the flask_security/utils.py file

Recently, I came across an issue while working with Flask-Security where the confirmation email was not being sent successfully. After some troubleshooting, I managed to resolve it by removing a specific line in flask_security/utils.py. The problematic lin ...

Flask decorator for rendering JSON views on Google App Engine

Currently, I am attempting to create a view rendering decorator for JSON in Flask by referring to this specific code snippet: http://flask.pocoo.org/snippets/18/ My challenge lies in the necessity of serializing GAE models as JSON, which the regular jsoni ...

Flask Blueprints cannot overwrite the static path

I am attempting to utilize Flask Blueprints for serving a multipage web application. Webapp structure: Landing page html->login->Vuejs SPA Flask structure: app/ client/ dist/ static/ js/ css/ ...