flask unit test: how to test request from logged in user

I'm writing some unit tests for my Flask web application and I'm trying to test the differences in the response between a request made by an anonymous user and a logged in user. I'm using the...

Is there a secure way to use React.js with a Python Flask backend for a multi-user, password protected site

I'm familiar with Flask for building simple webapps and using jinja2 as a template engine. However, I'd like to try out React.js as a front-end. The examples I've seen that use React.js with a...

Checking flash messages in flask application nose tests

On different input values posted to a url of my flask application, it flashes different messages, e.g. 'no data entered', 'invalid input', 'no record found', '3 records found'. Can someone guide...

Flask-Session extension vs default session

I'm using: from flask import session @app.route('/') def main_page(): if session.get('key'): print ("session exist" + session.get('key')) else: print ("could not find...

how to add flask-login to flask-admin

Login works great on my standard views, and the admin works great, but i can't seem to add login to my admin/yikes!!! It seems straightforward flask admin docs but when I add this section class...

How to combine py.test fixtures with Flask-SQLAlchemy and PostgreSQL?

I'm struggling to write py.test fixtures for managing my app's database that maximize speed, supports pytest-xdist parallelization of tests, and isolates the tests from each other. I'm using...

why the pytest fixture does not rollback data after each test function has run?

i write a pytest fixture to rollback data after each test function has run, which seems to make no sense. The fixture is below: @pytest.fixture(scope='function') def session(db, request): ...

How to run Flask Server in the background

I have set up Flask on my Rapsberry Pi and I am using it for the sole purpose of acting as a server for an xml file which I created with a Python script to pass data to an iPad app (iRule). My RPI...

Does __init__.py have to be in every directory of python application?

__init__.py are use to mark directories on disk as a Python package directories. lets say we have the files py/src/__init__.py py/src/user.py and py is on your path, you can import the code in...

Reading IIS Session Variables from Flask App with wfastcgi.py

I'm building a secured app with Flask 0.12 on IIS 7.0. The site is on a subdomain so its urls all begin with: https://<subdomain>.<domain>/<app_name>/ wfastcgi.py strips away these prefixes and...

"There was a problem with the requested skill's response" In Alexa Developer Console

SITUATION: So i followed a 3 video short tutorial by sentdex on youtube named "Alexa Skills w/ Python and Flask-Ask" parts 1, 2 and 3. Basically when i run this skill, alexa will read me the first...

Flask Client-Server Connection Timeout after given time

I have a flask app. I want the client-server connection to terminate if the server does not respond within a stipulated time (say 20 seconds). I read here that the session.permanent = True can be...

How to implement date picker using Flask-WTF forms

How should a date picker be implemented when using Flask-wtf? Have attempted using various examples from the web but none seem to work. See code for latest attempt. from flask import Flask,...

Problem with using the State variable in google api + Django

I'm trying to add the ability to save files to google disk to the django application. I took as a basis an example from the official documentation written in flask link import...

sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1054, "Unknown column 'detail.id' in 'field list'")

I set up a small website, where anyone can store 'name,email,phone' but when I retrieve data from database so I'm getting this error. I don't why? I'd spend two days to resolve this error but...

How to restrict access to routes in react-router-dom based on session?

I have a React front-end and Python back-end with user session management using flask-login's HttpOnly Session Cookies. How can I restrict react-router-dom routes based on this type of session...

ImportError: cannot import name 'Session' from 'flask_session' (unknown location)

I have the following code from CS50w, the file is application.py import os from flask import Flask, session from flask_session import Session from sqlalchemy import create_engine from...

YouTube API - Trying to fetch channel members

I'm currently trying to write a Python script to fetch my YouTube channel members using the YouTube API. I have created an OAuth Client and have gone through the necessary steps to setup all of my...

Get Dialogflow context parameters from a follow up intent in Python

I created a flask app in python to send text to Dialogflow in order to detect the intent and return the fulfillment text as response from it. Then I extended this to also return along the...

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column

I'm trying to create a model with SQLAlchemy (with Flask), but I cannot find out anywhere on the internet a fix to my problem. The error that it gives me is sqlalchemy.exc.OperationalError:...

" An error occurred initiating application server. Failed to launch application server" for PgAdmin 4 on WIndows 7

I have tried all possible solutions suggested on Stackoverflow for the above Error message received while trying to launch PgAdmin4 on Windows 7. For e.g. Running as Administrator, changing...

Failed to find attribute 'app' in '__main__'

Im trying to deploy a web app using flask to heroku using gunicorn. I've been trying for roughly 2 days but with no luck. I currently have this error: Failed to find attribute 'app' in...

Flask-Mail [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)

I'm developing a Flask application that implements a user registration system. The application uses Flask-Mail and itsdangerous to confirm a user's registration and reset their password via email....

Django-OIDC with keycloak - OIDC callback state not found in session oidc_states

I am trying to implement Keycloak SSO with Django API using OIDC. Getting below error message after requesting the call to Keyclock as a response SuspiciousOperation at /^oidc/callback/ OIDC...

Flask testing with pytest, ENV is set to production?

I have built a flask app and i would like to create a test suite. Reading around it looks like pytest is the way to go; however, I am finding it very difficult to understand how to get going, I...

Why can't I see the created database file in my working directory (Flask)?

Problem: I am new to creating a website on the flask and my code is running smoothly without any error, but I can't see the database file on my working directory or in my Project and I dont know...

Flask SQLAlchemy and Blueprints

I am still learning flask and I have created an restful API with SQLAlchemy. The app is getting to be big and I would like to split it up into multiple files. When I separate the routes section...

The pgAdmin 4. ImportError: DLL load failed while importing unicodedata: The parameter is incorrect

When running pgAdmni4 from PostgreSQL it throws an error. Know how to fix it? pgAdmin Runtime Environment -------------------------------------------------------- Python Path:...

Python with flask, Error: While importing 'app', an ImportError was raised

Trying to get an 'hello world' flask app running with Python 3.9.7. Folder structure: py-flask L app.py L README.md L__pycache__ Content of app.py: from flask import flask app =...

pymongo.errors.ServerSelectionTimeoutError error with MongoDB atlas and Flask

Hi I am trying to connect mongoDB atlas database to my flask api. when I use following code (with the correct password): from flask import Flask, jsonify, request, redirect from flask_pymongo...