Questions tagged [flask]

11583 questions
1

votes
1

answer
520

Views

Two Columns joining the same table with SqlAlchemy

I'm building a sport related application in Flask using SqlAlchemy. I've got a Game table that has a home_team and an away_team which both join to the Team table. I want to be able to declare the relationship between the Team table and the Game table but I'm getting an error saying Could not determ...
hammygoonan
0

votes
0

answer
2

Views

Render Template FLASK

I have a problem with reload page, when I click the button wchich is used to filtrate data witch using ajax script. In condition IF not working render template . Below sample code Python def viewchallenges(): categories = Categories.query.all() if request.method=='POST': category_id=Categories.quer...
Mican
0

votes
0

answer
7

Views

How to insert a token in headers of responses of all page after login?

I'm trying to make user insert a jwt generated token to all requests after login to my flask web app. For example I want to redirect to main page by inserting a given token in header of response after login to app. This is what I want to do: @app.route('/', methods=['GET', 'POST']) def login(): @aft...
mohammadreza
0

votes
1

answer
15

Views

I can't get my “event.preventDefault” to work when submitting a form through button in overlay

As the title says, I can't get my event.preventDefault to work on a submit POST request of my form. Using standard js, flask, css, and html. ASFAIK there are no errors anywhere. If I can just have the overlay stay where it is and still send the post back to flask that would help me a tons!! Thank y...
tinnick
1

votes
1

answer
1.9k

Views

Global variables in Flask templates

Probably not the accurate title since i am new to flask/python. I am working on an internal tool which will be used by different teams. Each team has different stages of their deployments e.g., alpha, beta|test, prod and they also have multiple regions e.g., NA, EU, AP etc ... Right now i when i am...
Em Ae
1

votes
2

answer
627

Views

sqlalchemy + flask: class is not defined

i'm using sqlalchemy + alembic + Flask and i can't map circular classes. apps/users/models.py: class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) email = Column(String) password = Column(String) session = relationship('Session', back_populates='user', cascade='all,dele...
1

votes
1

answer
1.4k

Views

Flask-SQLAlchemy Query records by relationship attribute

In the app I've been working on uses Flask-User and their suggested models for authorization control. Here's an example: class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) # User Authentication information username = db.Column(db.String(50), nullable=False, unique=True) pa...
1

votes
1

answer
1.8k

Views

python flask restfull receive image

Hi I am having trouble receiving a file on my flask server from my python client I am saving the screenshot in memory but am unable to receive it on the server end. I appreciate any help I can get I am lost with what my requests.post has to be. Server Code: @app.route('/upload', methods=['POST']) d...
w40
1

votes
1

answer
144

Views

mutate() got multiple values for argument 'name'

I want to query createThemes to my graphql. My graphql query is: mutation{ createTheme(name: 'qwe'){ theme{ id } } } So it errors: mutate() got multiple values for argument 'name' Can you solve and explain why its printing such error. My code below: from models import Theme as ThemeModel, Topic as T...
1

votes
1

answer
344

Views

gunicorn not found when running a docker container with venv

I'm trying to run a Docker container which complains with the error message: /bin/sh: gunicorn: not found. Firing up the server locally without Docker works fine. And building the image also works fine. I'm new to docker so I don't know if anything looks weird in my Dockerfile.. My Dockerfile: FROM...
Weblurk
1

votes
3

answer
97

Views

Multiple Highcharts in one page - only one chart displays

I'm in the process of creating a Flask application, for the charting element I want to use Highcharts, I've managed to get one chart to display on a webpage but as soon as I try to display multiple charts only one renders. I have tried a number of things to start, changing variable names, checked li...
Woody_1983
1

votes
3

answer
61

Views

Elegant way to return json field if field is null in Python

I've a dumb question about my flask REST API. If i have a user model with a lot of information and i want to return it as json. But some of the information is still don't have any value (NULL). What's the elegant way to return it as a empty string or another default value instead of returning it as...
ikhsan
1

votes
1

answer
40

Views

Work on multiple branches with Flask-Migrate

I'm using Flask-Migrate (Alembic) to manage SQLAlchemy database migrations. I'm working on two different branches with different migrations. If I switch branches, I get an error that the migration is not found. If i merge this branches into the parent branch, I need downgrade migration's on both mu...
Anna
0

votes
1

answer
19

Views

Python Flask - how to make it run forever (even after server reboot)?

I have a running Flask app that is working fine on a Linux (CentOS) server. To make it work in the background - I started it within a screen session (so that can monitor as well when needed). There is a scheduled downtime of a server every night but then next day - all screen sessions are gone (kill...
Joe
0

votes
2

answer
17

Views

Flask send_file / send_from_directory returning 200 status code but not the file

I'm trying to send a file from my Flask app through send_file() or send_from_directory() without success. The request returns a response with status_code=200 but no file is being downloaded. I have verified the functions work as they return errors when the file or directory does not exist This is th...
dariuscosden
12

votes
2

answer
393

Views

Python Flask as Windows Service

I am trying to get a Flask app to run as a Service in Windows. I have already tried to implement a solution as suggested here and here without success. I have a simple folder with just two files: Project | +-- myapp.py +-- win32_service.py Inside myapp.py is a simple Flask app: from flask import...
drec4s
0

votes
0

answer
8

Views

Why does this thread runs twice concurrently

I have a background thread in a very primitive rest server that I planned to build. The only problem is this background thread seem to run twice, the code is here: import threading feeder = Feeder() app = Flask(__name__, template_folder='templates') def runfeeder(): print('RUNNING FEEDER FOR {}th TI...
Rocky Li
1

votes
0

answer
92

Views

Simple GET request in cURL is unresponsive

I wrote python code for a very basic server to test cURL on my terminal (Mac OS X) from flask import Flask node = Flask(__name__) @node.route('/greet', methods=['GET']) def greet(): print 'hello, world' return 'hey!' node.run() However, when I ran the code on my terminal, using $ python testblock....
ztlm622
1

votes
0

answer
36

Views

Model example for make_declarative_base()

I've upgrade Flask-SQLalchemy from 2.1 and since 2.2 version this function requires a model parameter. Can somebody show an usage example for this?
Sht0p0r
1

votes
0

answer
394

Views

Upload a file asynchronously to S3 in Flask request

I have a Flask API that uploads files. Currently I am working on scaling the application. I have a scenario where a user uploads a large file - in that case, I save the file locally in the flask request and then kick off a celery task that then uploads it to S3 (and does other things). My problem n...
George B
0

votes
2

answer
24

Views

How to read in user input on a webpage in Flask

I'm trying to create a basic web app that has an HTML form on the root landing page, and then after submission, run a postgresql query with the desired input and redirect the user to a page with a generated matplotlib chart of their input. In my main function, I have the following: @app.route('/', m...
danielschnoll
1

votes
2

answer
1.5k

Views

No module named sqlalchemy

I have tried using sudo easy_install sqlalchemy, pip install sqlalchemy and pip install flask-sqlalchemy. I have also tried installing and uninstalling sqlalchemy and flask. I get the error Traceback (most recent call last): File '/usr/lib/python2.7/multiprocessing/process.py', line 267, in _bootstr...
jc13
1

votes
0

answer
293

Views

error: [Errno 10054] An existing connection was forcibly closed by the remote host Python

I'm using flask to run a simple web server to display my video output from the webcam as an mjpeg, i need to use the link to stream it on Mission planner, my code is: from flask import Flask, render_template, Response from camera import VideoCamera import time app = Flask(__name__) @app.route('/vide...
Saadat Shafeeq Lone
1

votes
0

answer
190

Views

how to continue with uploading a csv file to postgres using flask+panda

i am new to python and postgres and am trying to build a simple flask web app. a user can choose a csv file, press upload, and it will create a table in postgres on my server with the table in the csv. a simple copy paste. my html code: upload my python module: from flask import Flask, render_templa...
Tal Alterzon
1

votes
1

answer
286

Views

Detecting supported interfaces in Flask-Ask Alexa Echo Show

I am trying to build a voice skill for both Echo Show [Screen Enabled] and Echo Dot [Audio only]. Apparently the response directives have to be changed depending on the device if not, it would result in 'Alexa having trouble accessing the skill'. How do we determine the supported interfaces in Flask...
Naveen Vijay
1

votes
0

answer
260

Views

Flask Restful Reqparse required=True Error handling

I am using flask_restful.reqparse for parsing arguments. Now I want 'name' argument must be required. So I wrote this: from flask_restful import reqparse parser = reqparse.RequestParser() name= parser.add_argument('name', required=True, help='name is missing') Now I want to handle error that name is...
Parth Chauhan
1

votes
1

answer
171

Views

How to ignore case when filter value in database with python [duplicate]

This question already has an answer here: Case Insensitive Flask-SQLAlchemy Query 2 answers I've tried to find an answer of my question. And I find some answers but I don't know how to apply those to my question. I'm using flask sqlalchemy. This is my python code for getting product list. def get_p...
Canet Robern
1

votes
0

answer
753

Views

Flask Countdown Timer without Sleep [duplicate]

This question already has an answer here: How many concurrent requests does a single Flask process receive? 4 answers Handle Flask requests concurrently with threaded=True 2 answers Display data streamed from a Flask view as it updates 1 answer I'm writing a web app with Flask and when I try to c...
user3246092
1

votes
2

answer
119

Views

why math.ceil return a integer in flask shell command?

ENV: python: 2.7.5 flask = 0.12.2 flask-cors = 2.0.1 flask-script = 2.0.5 start a python shell: $ python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type 'help', 'copyright', 'credits' or 'license' for more information. >>> import math >>> math.cei...
pangpang
1

votes
2

answer
183

Views

how do I get Flask blueprints to work with multiple domains?

I have a Flask app and want it to work for www.domain-a.net and www.domain-b.net behind Apache + WSGI. I can get it to work for one or the other, but can't find a way to get it to work for both. It seems that the domain which registers first is the only one that works. Preferably this would work by...
robbie.huffman
1

votes
0

answer
97

Views

Bokeh plots not displaying after successful AJAX request and div HTML update

I have a Flask view that returns the div, script tuple from components call. This is returned as a response to a JQuery-generated GET request, where, upon success, I select the corresponding plot div and plot script divs (in that order) and update their inner HTML as seen on many examples. Nothing b...
Jona Q
1

votes
1

answer
352

Views

how can I pass curent_user from flask-security to a pluggable view function?

I have a flask app that uses flask security for authentication. I want to use graphql with graphene to fetch data but I'm having trouble accessing the current_user proxy which is I've always used to resolve requests. graphene only provides a customized pluggable view which is understandable but it c...
Kasra Magmont
1

votes
1

answer
230

Views

SQLAlchemy scoped_session is not getting latest data from DB

I'm rather new to the whole ORM topic, and I've already searched forums and docs. The question is about a flask application with SQLAlchemy as ORM for the PostgreSQL. The __init__.py contains the following line: db = SQLAlchemy() the created object is referenced in the other files to access the DB....
SharedObject
1

votes
0

answer
120

Views

Python - Flask API service - Loop through API data sources, cache, and give rapid feedback on call

I'm trying to develop an API service that after collecting data continuously from different sources, elaborate that data, and keep that information ready from being requested from another service. I'm using Flask and it's working on top of a single thread. My problem is about the slowlines accessin...
entalpia
1

votes
0

answer
391

Views

Error when accessing Google OAuth from Docker container : device_id and device_name are required for private IP

I have a dockerized flask app running from a docker-machine with IP 192.168.99.100 that is trying to access Google OAuth. However, I am getting the following error: Error: invalid_request device_id and device_name are required for private IP: http://192.168.99.100:8001/login/authorized I tried the s...
Ron
1

votes
0

answer
357

Views

Python-Stripe: How to catch stripe.error.CardError in Flask App

I'm having the same problem as the OP here: Stripe not Throwing Charging Error in Python Unfortunately the solution does not work for me, my error won't be caught. I have a little route in Flask that takes in some data, does some DB work and finally will create a charge via stripe. I have currently...
kidman01
1

votes
1

answer
278

Views

Passing HTTP parameters from request url with Flask

Below is the code I'm using for Simple REST API. It is working fine. The REST URL is like http://127.0.0.1:8080/sample/100 But I need to pass 100 as a key value pair like http://127.0.0.1:8080/sample?runtime=100. Is this possible or any other python library that will help app = Flask(__name__) api =...
Krishna
1

votes
1

answer
1.8k

Views

flask image not update on html page

I have flask web app that user can upload image and display histogram i save my histogram image in static folder and delete it when user try to up new image @app.route('/upload', methods=['POST']) def upload(): file = request.files['file'] filename = secure_filename(file.filename) file.save(os.path....
Avause
1

votes
1

answer
237

Views

Tensorflow Serving Client Script Hangs At stub.predict.future()

This is my first time asking a question here so I will try to be descriptive. I am relatively new to python and tensorflow, and have been learning it specifically for a project. I am currently working to deploy a tensorflow model using tensorflow serving and flask with wsgi. I have been following th...
RTri
1

votes
0

answer
1k

Views

fileobj must implement read

On Elastic Beanstalk I'm using the following Python code to handle a POST request and upload a file to a S3 bucket. However, I get the following error: fileobj must implement read after reading Flask's FileStorage documentation, I've tried to substitute f with f.stream, but then I've got: expected s...
stochazesthai

View additional questions