Questions tagged [flask]

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

Jinja: generating recursive json outputs

I am having trouble rendering this specific json object using the jinja template engine view full json object here Shortened version: { "data": { "domain.org": { "type": "folder", "children&q ...

Elusive Appearance of the Flask Flash Message

I have developed a web application using Flask that allows users to upload files to an S3 storage. However, I would like to enhance the user experience by showing them the progress of their file uploads in real-time. To achieve this, I am utilizing Flash t ...

What are the steps for capturing video using openCV in a python program?

I am facing a challenge in figuring out how to capture a video using openCV. While I have managed to display the video on an html template with the existing codes, I am uncertain about which codes are needed to actually record the video. -camera.py- i ...

Can a unique and optional attribute be defined for a class model in (Flask) SQLAlchemy?

I am looking to define a unique and optional attribute in Python Sql Alchemy with Flask and Flask-SQLAlchemy. Is this achievable? membership_number = db.Column(db.String(120), unique=True) ...

Issue with WTForms form submission: validation errors not displayed despite form not being properly submitted

I'm having issues trying to implement file uploads using flask-uploads. I've encountered some obstacles while working on it and I need some assistance. Below, I will display my flask view function along with the HTML code, in hopes that someone can help me ...

Flask does not provide a direct boolean value for checkboxes

After struggling for a week, I am still lost on where to make changes in my code. I need the checkbox to return a boolean value in my Flask application. Below are snippets of the relevant code: mycode.py import os, sqlite3 from flask import Flask, flash ...

Flask Template Failing to Load Local CSS

Hello there, I am currently working on integrating custom CSS into my Flask application. While I had no issues loading Bootstrap, I seem to be facing some difficulties with my local CSS. Below is the method I am using to load my CSS: <link rel="st ...

Sending information to a Flask application using AJAX

Currently, I am working on transferring URLs from an extension to a Flask app. The extension is able to access the current URL of the website. I have set up an AJAX request to connect to Flask, and the connection is successful. However, when trying to send ...

Secure your Flask forms with CSRF token validation middleware

I'm handling an html form and want to make sure that all submissions originate from my website. I've noticed others using a key for this in Django, and I'm considering implementing something similar. Is there a recommended approach for achieving this in Fl ...

Ways to extract information from a table cell located next to a table cell with colspan

As a beginner in web scraping, I am gradually making progress. However, I'm facing a tough challenge with this particular task. My goal is to extract data from the ESPN NBA boxscore website: I aim to scrape the names of players labeled as "DNP" (Did Not ...

A guide on incorporating background threads in Flask:

I have a complex calculation that I need to perform, and because of the gateway timeout issue, I am looking to run the calculation in a background thread. I attempted to use Python threading but encountered some difficulties. import time import threadin ...

Which JavaScript framework tackles the challenges of managing asynchronous flow, callbacks, and closures?

I have a strong aversion to JavaScript. I find it to be quite messy and disorganized as a language. However, I recognize that my lack of proficiency in coding with it may contribute to this perception. These past few days have been incredibly frustrating ...

Is there a way to utilize BackgroundScheduler for updating a variable within a Flask route?

Can you help me figure out how to make the current_time variable update each time the webpage is reloaded in Flask? from flask import Flask, render_template app=Flask(__name__) import time from datetime import datetime from apscheduler.schedulers.backgro ...

Potential solution for communication issue between Angular CLI and Flask due to cross-origin error

Initially, the user id and password are submitted from the UI (angular) to Flask: public send_login(user){ console.log(user) return this.http.post(this.apiURL+'/login',JSON.stringify(user),this.httpOptions) .pip ...

Error: recursion depth reached the limit (FLASK)

Hey there, experiencing an issue with my Flask application. Here's the recursion error I'm facing: *File "/Users/Desktop/Flask_Blog/flaskblog.py", line 20, in __repr__ return f"User('{self.username}', '{self.email}', '{self.image_file}')&quo ...

Exploring the capabilities of arrays within Ajax

Below is the original code I wrote in JavaScript: var wt_val = []; for (i = 0; i<human_wt.length; i++){ var mult; mult = data_list[basket_list[button_port_name][i]].map(x => x*(wt[i]/100)); wt_val.push(mult); ...

best practices for dealing with blank lines in logging request headers within a flask application

Is there a way to log request headers in the logfile without getting all those blank lines in between? I've tried using: logging.debug("Headers:{0}".format(request.headers)) but the output is full of empty lines. I noticed there are '/r/n' characters bet ...

Error encountered during unittest execution: AssertionError was thrown

While writing a unit testing function for my Flask view, I encountered an AssertionError. The error message I received is as follows: Traceback (most recent call last): File "C:\Users\Administrator\Desktop\eind\Joy-1\web ...

Steps for importing the mongo variable from the app that is bound to the application

I have two files, app.py and views.py app.py from flask import Flask from flask_pymongo import PyMongo app = Flask(__name__) app.config["MONGO_URI"] = "mongodb://local:27017/local" mongo = PyMongo(app) from views import profileview profileview.register(ap ...

How to send a JavaScript variable to Flask and trigger an AJAX reload action

Introduction: I have explored similar inquiries and attempted to apply relevant code/concepts but without success. -https://stackoverflow.com/questions/43645790/passing-javascript-variable-to-python-flask -https://stackoverflow.com/questions/10313001/is- ...

Unable to process form submission with AngularJS + Stormpath

I am facing an issue with form submission. Even though I believe that the login and password data are being sent correctly, nothing happens when I submit the form. I am attempting to submit the form without using ngSubmit because it is not feasible in my s ...

Revamp the HTML page by automatically refreshing labels upon every Get request

My HTML webpage requires real-time updates for one or more labels. To achieve this, I have incorporated CSS and JS animations into the design. Currently, I am utilizing Flask to handle all the calls. I face a challenge where I need to consistently update ...

How can we call a function in HTML from an external JavaScript file?

I am attempting to utilize a function that I have defined in my .js file within my HTML document. js/newsalerts.js function decodeHTML(html) { //https://stackoverflow.com/a/2989105/4650297 var tempDiv = document.createElement("DIV"); tempDiv. ...

CORS blocked the HTTP request due to the absence of the Access-Control-Allow-Origin header, although the header is actually present

Recently, I encountered an issue while working on a project using Python with Flask. I had created a REST API and needed my Vue app to interact with it and fetch data. However, I kept receiving an error message stating "No 'Access-Control-Allow-Origin' hea ...

Switching images dynamically using Flask and JavaScript

I'm currently working on Flask and encountering a perplexing issue. I'm attempting to update an image using JavaScript, but I am getting these errors from Flask: ... 12:05:34] "GET / HTTP/1.1" 200 - ... 12:05:38] "GET /img/pictur ...

Using Flask for AngularJS authentication

I am currently in the process of creating a web application utilizing AngularJS along with a REST-API developed using the Flask framework. This application is broken down into two main components: The first part allows users to interact without loggin ...

SQLAlchemy is unable to generate relational column connections

Thank you in advance. I'm currently working on an application using Flask and SQLAlchemy. When I first started, I initialized the database by running flask db init. $ flask db init Creating directory /Users/xxxx/app/migrations ... done Creating dire ...

Is there a way to simulate pressing shift + enter key with Python using Selenium Chrome WebDriver?

I recently developed a bulk WhatsApp message sender application that allows for sending multi-line text messages. However, I encountered an issue on WhatsApp web where pressing enter sends the message right away. My goal is to have it press shift + enter ...

The port number for localhost remains constant

Any ideas on resolving the issue of an app running on the wrong port? I would like my localhost to use port 8080 instead of 5000. I attempted to run port 8080 through the terminal, but it was unsuccessful. Port 5000 is not compatible with my current proj ...

Struggling to transfer information from JavaScript to Python Flask?

I am currently working on a basic configuration where I need to send a string to my Flask application through Ajax, but unfortunately, I am encountering Error code 400: Bad request. Here is the JavaScript code snippet: headers = { 'Content-type&a ...

Troubleshooting Issue with Post/Get Request in AJAX and Flask Framework

My current project involves building a YouTube scraper webpage purely for educational purposes. I have created a web page with a text box to enter search queries and a search button. When the button is clicked, an Ajax post request is sent with the text bo ...

``We can showcase API data using various endpoints and then present it on a web page using

Hello from Argentina! I'm new to programming and recently started a Flask project. I've successfully displayed information from an API using one endpoint and rendered it with Flask. However, I'm now facing the challenge of displaying informa ...

The email validation feature in Flask WTForm for Python does not accept dashes as valid characters

I need help validating an email input field in Flask for a user. Currently, I am using WTForms' Email validation method, but it does not allow users to include dashes in their email addresses. Here is my code: from flask_wtf import FlaskForm from wtforms i ...

Combining Flask with Celery: Maximizing Efficiency with Parallel Processes

My Flask Celery app instantiates the celery instance. I'm aware that I can add a normal Flask route to the same .py file, but would need to run the code twice: To run the worker: % celery worker -A app.celery ... To run the code as a normal ...

Issue with Flask-Cors in Nuxt with Flask and JWT authentication implementation

I have exhausted all the available solutions to my issue, but I still can't seem to pinpoint the problem. Despite trying every solution out there, nothing seems to be of any help. Every time I make a request, the browser blocks it due to CORS Policy. My ...

jinja2.exceptions.UndefinedError: The variable 'asset' has not been defined

Currently in my project, I am using a Python backend to fetch data from an API and then rendering it through Flask to the Vue.js frontend. However, I have encountered an error titled that is causing some issues. I have double-checked and printed the varia ...

Assign a CSS class to a specific option within a SelectField in a WTForms form

Could someone explain the process of assigning a CSS class to the choices values? I am looking to customize the background of each choice with a small image. How can this be done using wtforms and CSS? class RegisterForm(Form): username = TextField( ...

Error encountered: Failure to construct URL for endpoint 'Bookdetails'. Have you overlooked supplying values for the parameter 'book_id'?

I have been troubleshooting this issue and reviewed similar threads, yet despite verifying all options, the problem persists. My code includes: application.py @app.route("/Booksearch/<int:book_id>", methods=["GET", "POST"]) def Bookdetails(book_id ...

Sending JSON data from an iOS app to a Flask backend

Within my Flask Python web application, I store certain parameters in SessionStorage to later send back to Flask and save this data as a text file. Interestingly, the process functions perfectly on PCs and Android devices but encounters issues on iOS devi ...

Retrieving information from an ImmutableMultiDict in Flask

I'm currently in the process of learning how to utilize ajax with Flask. My approach involves sending an ajax request and handling the data as a post request within my Python file. The code snippet in my HTML file: var data = {"name":"John Doe","age ...

Tips for effectively retrieving Geocode API data in Python

Utilizing Flask along with Google's geocode API to retrieve data on a city, my goal is to return its coordinates in JSON format. Below is the relevant code snippet. from flask import Flask, request, json import googlemaps from datetime import datetime imp ...

Flask - Refreshing Forms Dynamically

In an effort to enhance the responsiveness of my app, I am looking for a way to prevent the page from reloading every time a POST request is sent. My current setup includes a dynamically generated form with input fields designed like this: <div class=&q ...

What is the best way to retrieve a subprocess in a Flask application?

I have a question regarding my Python Flask script. I am fairly new to Python and Flask, so please bear with me. The second decorator in my code is supposed to return the subprocess to the /results page. While the ping test does print in the terminal, I ...

Generate a fresh jpg file upon user triggering the route in Flask using Ajax

app = Flask(__name__) @app.route('/' , methods = ['GET', 'POST']) def index(): print("hello") if request.method == 'GET': text = request.args.get("image") print(text) base64_img_bytes = text.en ...

Updating an image using AJAX and Flask

I have a situation in HTML where I need to constantly update an image file with the latest images that come in. Below is the Flask code snippet: @app.route('/uploads/update_file', methods=['GET', 'POST']) def update_file(): ...

Encountering a 500 error when deploying a Flask app to Heroku stemming from issues with the create_app

After successfully running my app locally with "Flask run", I encountered an error when trying to deploy it on Heroku. The structure of my app is similar to the microblog flask tutorial with blueprints. Upon accessing the deployed website, I received the f ...

Tips for personalizing the appearance of API output?

Currently, I am working on building a basic API using Python and the Flask Framework. While I am able to generate the desired output, I am facing an issue with the way it is being presented - in alphabetical order. My goal is to customize the output to dis ...

Flask and the steps to modify CORS header

While working on my localhost, I came across a CORS error when building an application to handle search queries for a different domain. The specific error was: "Cross Origin Request Blocked... (Reason: CORS header 'Access-Control-Allow-Origin' missing)". A ...

Is it possible to conceal or encrypt JSON data or header information in HTTP requests and calls?

I am currently developing a full stack website with Flask, Vuejs and SQLite3. I have been using axios to make backend calls from the frontend. However, I noticed that when I make 'GET' requests using axios (Vuejs) to the backend on a particular route, all ...

Setting the sender email address when using the Flask Mail module is a crucial step that ensures

When sending emails from a website's contact form using Flask Mail, I encounter an issue. The email recipient is set correctly, but the "from" field in the received email defaults to the SMTP MAIL_USERNAME, rather than the sender's email entered ...

What is the process for adding parameters to a Fetch GET request?

I have developed a basic Flask jsonify function that returns a JSON Object, although I am not certain if it qualifies as an API. @app.route('/searchData/<int:id>',methods=["GET"]) def searchData(id): return jsonify(searchData(id)) Curr ...

The flask application encounters a 404 error when trying to access the favicon.ico file

Upon reviewing my logfile, I noticed numerous entries indicating attempts to load files like /favicon.ico GET - /favicon.ico GET - /apple-touch-icon.png GET - /apple-touch-icon-precomposed.png I have researched this issue extensively online, but have bee ...

When a node or edge is clicked in Cytoscape, display its attributes in a table format

Hello, I am new to using cytoscape.js and currently working on rendering shallow networks in a Flask App. At the moment, I have managed to display node and edge attributes when hovering over them, but the information is shown in a format that is not very ...

creating flask restful api with flexible endpoints and access control

Having recently started learning Flask, I have challenged myself to build my own API in order to become more proficient with the platform. Purpose of the API: Authenticated users should be able to access the endpoint www.mydomain.com/api/ and perform ...

Is the commented out cron task in GAE being executed?

Recently, I was involved in a project that hosts its application on GAE. During a late-night deployment to the QA server (also on GAE), a cron job in the cron.yaml file was commented out. To my surprise, the cron task ran as soon as the deployment was com ...

Access Flask variable in JavaScript code

Currently working on a CTF challenge, my query is not seeking assistance in solving it, but rather pertains to syntax. The task involves retrieving the secret key from Flask server's configuration. This key is stored within the app.secret_key variable, and ...

Python sends back a list containing garbled characters to Ajax

Need help fixing the output of a Python list returned to Ajax, as it appears strange. ap.py @app.route('/_get_comUpdate/', methods=['POST']) def _get_comUpdate(): comNr = request.form.get('comNr') com_result = COMPort("ON","COM255",comNr) ...

Flask - "Error: Detected a line break in the header value. This could pose a security risk"

Just starting out with python and experimenting with flask. Created a simple web page where ASCII art can be uploaded, following a tutorial from an Udacity course. However, when uploading ASCII art, I encountered an error message: ValueError: Detected ne ...

Turn off Jinja2 Template Caching

I want to turn off Jinja2's template cache feature. After some research, I discovered that there's a cache_size parameter available for the jinja environment. My current implementation is as follows: app.jinja_env = jinja2.Environment( cache ...

When attempting to download a PDF file from Flask to the client, the file appears to be

I am encountering an issue with my Flask server that sends a PDF file using the send_file function. When testing this route on Postman, I am able to view and download the PDF successfully. However, when attempting to download it through my React frontend, ...

Using get_json() in Flask server is not possible when JSON data is sent from an Android device using MultiPartEntityBuilder

My aim is to send a JSON formatted string from an Android device to a Flask server. To achieve this, I am utilizing Apache MultiPartEntityBuilder for sending, as I also need to include an image file in the same http post message. While I have successfully ...

Reorganize the layout of columns in the Flask-Admin list display

In the Flask-Admin list view (ModelView) of my user model, I have successfully excluded some fields and customized headers. The functionality is as expected, and I have even taken the extra step to modify the default list template so it aligns with the sty ...

Issue: "StoreController Undefined" error in Python Flask + Angular application

In the python flask application that I have built with Angular JS for the front end, there are three main files. app.py import json import flask import numpy as np app = flask.Flask(__name__) @app.route("/") def index(): ...

Retrieve the value from a checkbox using Flask and then transfer the extracted data to a different template

I am currently working with Weasyprint to showcase some Jinja templates within a Flask Web App. Here is the JSON data I am using: value=["1","2","3","4"] My goal is to pass the 'value' variable to another Jinja template within an if statement. {% if (v ...

Persistence of Flask-SQLAlchemy changes does not apply

Building a web application where user actions can impact bar graphs, some changes are not saved. Reloading the page sometimes shows the updated bar graphs, indicating that the user's actions were saved. However, upon further reloads, the changes may or may ...

Having trouble sending an array from Flask to a JavaScript function

As a newcomer to web development and JavaScript, I'm struggling to pass an array from a Flask function into a JavaScript function. Here's what my JS function looks like: function up(deptcity) { console.log('hi'); $.aja ...

looking to get into deeper levels of JSON data with json.load

I have implemented Hufman's Honeywell Python code to extract data from the MyTotalConnectComfort website. The code can be accessed here. I made adjustments to the code for compatibility with version 2.7 and integrated Flask into the process. Upon calling ...

Having trouble adding your own styling to bootstrap-4 using a custom CSS file?

Here is the code I used to connect my two stylesheets, with the custom css file being linked second as per what I believe is the correct way to do it. <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href=" ...

What are the steps for generating website endpoints using search query outcomes?

I am currently working on a ReactJS website as a part of my web development bootcamp project. One interesting feature I have incorporated is a search functionality that uses Flask routes to connect ReactJS endpoints (../Language.js) with my Sqlite3 databa ...

Creating API documentation for several endpoints in one .yaml file using Python Flask Blueprints

Hey there! I'm currently working on organizing the API documentation for a blueprint by consolidating it into a single .yaml file. However, I seem to be facing an issue with flasgger not recognizing the correct definition within my current file structure a ...

Flask React constantly live at Localhost:5000

My current dilemma involves a rather peculiar situation with my flask/react app. Initially, everything was running smoothly on localhost:5000 via Flask. However, after closing the terminal application, the server continued to run inexplicably. Now, whene ...

Flask encountering issues when parsing correct arguments in HTTP request

I am currently facing an issue with my flask server running through gunicorn and nginx where it is not parsing certain characters like the plus sign (+) correctly in the arguments of the http messages. For instance, when I check the nginx log, I see: [04 ...

Flask Server produces a response with a considerable delay when accessed through AJAX

I am currently running 2 servers on localhost, each with different ports. One of them is a basic flask server in Python and its code is provided below: from flask import Flask,jsonify from flask_cors import CORS app = Flask(__name__) CORS(app) @app.rout ...

When attempting to use the jsonify method on a variable within an html file, the output is not displayed

Is it possible to store "jsonify" in a variable? I find the pure json format of "return jsonify(data)" unappealing, so I am looking for a way to enhance it using an HTML template with proper indentation. Here's the python code I have: from flask import Fl ...

Failed attempts to retrieve the binary large object (BLOB) from SQLite using Flask SQLAlchemy results in a null

I'm facing an issue while attempting to retrieve a BLOB (LargeBinary) object from SQLite using Flask-SQLAlchemy. The error message I'm encountering is: TypeError: must be string or read-only buffer, not None. This is the code snippet that I am working wit ...