Questions tagged [flask]

11601 questions
1

votes
0

answer
97

Views

Docker-compose: bind Celery to Postgres database

My Docker app runs with Flaskas backend and Celeryas an asyncronous task manager. Task results are then dumped in a SQLalchemy database owned by Postgres. However, I am not being able to make Celery interact with Postgres. STRUCTURE docker-compose-dev.yml web/ entrypoint.sh celery_worker.py migrati...
data_garden
1

votes
2

answer
2.5k

Views

Flask - 404 not found

I am a newbie in the flask development this is my first program in the flask but it shows me this error: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. & this is my code from flask import Flask app = Flask(__name__) @app.rout...
Roxas Zohbi
1

votes
2

answer
1.7k

Views

Using variables across Flask routes [duplicate]

This question already has an answer here: Are global variables thread safe in flask? How do I share data between requests? 2 answers I am learning Flask and have a question regarding use of variables in the context of routes.For Example, my app.py: from flask import Flask, render_template app = Fla...
James Wonder
1

votes
1

answer
1.4k

Views

Deploying Flask app on CherryPy server

I was trying to deploy my Flask app on CherryPy server. I liked its simplistic and minimalistic nature. So I PIP'ed CherryPy like below pip install CherryPy-15.0.0-py2.py3-none-any.whl and wrote script like below -very common suggested by many sources from cherrypy import wsgiserver from hello im...
Kay
0

votes
1

answer
17

Views

Python Flask Jinja2 css Style

I'm trying to use style sheet in flask and apparently it does Not work properly. I'm attaching a screen shoot to see how i have structured my app. my problem when I loaded my homepage I did not see the syle file applied, more I have inspected my chrome I do see only an empty style.css file . Plea...
koul
0

votes
0

answer
3

Views

Flask_kerberos KrbError: ('Principal not found in keytab', -1)

I am trying to integrate kerberos with flask/python. I have followed the steps in: https://flask-kerberos.readthedocs.io/en/latest/ I get the error mentioned whenever I try to get principal details. principal = kerberos.getServerPrincipalDetails('http', '10.113.41.11') This is my keytab details: Ke...
user3027865
1

votes
1

answer
2.7k

Views

How can I run a python script from within Flask

I have a Flask script which creates a website and prints some data dynamically. - The data which it prints should come from another python script. The current problem that I'm facing is that if I put the line that executes the python script before the line that executes the Flask app, it will run th...
Jack022
1

votes
1

answer
276

Views

Flask-sqlalchemy-Marshmallow nesting Schema not working

Basically what i want to do is, join 2 tables 'users' & 'company' and get the users with their relevant company details . this is the user model: class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) firstname = db.Column(db.String(10), nullabl...
Malika
1

votes
1

answer
687

Views

What does netloc mean?

I'm learning to make login function with Flask-login, and I'm facing with this code in my tutorial that I'm following: @app.route('/login', methods = ['GET', 'POST']) def login(): if current_user.is_authenticated: return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): use...
Harvest 1018
1

votes
1

answer
303

Views

Swagger with Flask-Restplus, API and multiple Blueprints

I'm building a very complex microservice using Flask and Flask-Restplus. It will have many endpoints, thus I'm organizing each endpoint into a separate Blueprint. Currently, I'm struggling with the usage of Flask-Restplus and API using multiple Blueprints in combination with swagger I want to be abl...
dacoda
1

votes
3

answer
54

Views

Pass variable from Flask HTML Template to JavaScript file for use

I am trying to pass a variable from Flask, to an HTML template, and then use that variable in a separate JavaScript file. routes.py fav_photo_index = Photo_Index() @app.route('/slideshow', methods=['POST', 'GET']) def slideshow(): cur_image_index = fav_photo_index print(cur_image_index.index, image_...
BruceWayne
1

votes
1

answer
37

Views

If the user visits my flask website from his/her email; how can I get his/her email address?

If the user has a mail message containing a link to my webapp which is built in flask. The user clicks the link and visits my site. The question now: how can I configure my flask app to detect that this user has visited the site via email?
0

votes
0

answer
5

Views

How to render items in succession with Flask/Jinja2?

I'm trying to cycle through a list of variables on my application's front-end. The only caveat is I want the variables to cycle through a list showing one variable at a time. How can I achieve this? Is there some functionality in Jinja2 that allows you to do this? {% for x in [1,2,3,4,5] %} {{x}} al...
Adam Roman
0

votes
0

answer
4

Views

how to fix not CountVectorizer - Vocabulary wasn't fitted.while deploying a ml model in flask

from sklearn.feature_extraction.text import CountVectorizer import flask import pickle with open('model/KTcategory-predictor.pkl', 'rb') as f: model = pickle.load(f) with open('model/KTtfidf.pkl', 'rb') as f: tfidf = pickle.load(f) app = flask.Flask(name, template_folder='templates') @app.route('/',...
Kanav Talwar
0

votes
0

answer
12

Views

What is the equivalent of entity framework in Flask?

When I worked with c# on asp net core, I made que models first and then created the database. When creating the models, I had for example, a list. So the models where linked. Example, a user had a list of posts. Using asp net core it was just pressing a few buttons and the program would create a dat...
Max
0

votes
0

answer
4

Views

request.form.getlist() not working with data from AJAX request

I'm having issues with checkboxes sharing the same name in Flask. Specifically, the form has a checkbox for each project, and I need to get a list of project ID's for each project that the user checked in the form. In the HTML, each project has a checkbox with name = 'project' and value = the proje...
Ethan Jensen
0

votes
0

answer
21

Views

Flask PermissionError: [Errno 13] Permission denied

I am trying to run a Flask application using /opt/mount1/python35/bin/python3.5 notification.py and I am getting the following error: WARNING:tensorflow:From /opt/mount1/python35/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.fram...
dp7
1

votes
1

answer
24

Views

Flask - Detecting when a function has finished running and visually indicating to the user

I have a button the user can press, it calls a function and nothing can happen until the function has finished executing. Is it possible to let the user press the button, call the function, but continue using the site and when the function has returned its output let the user know. @app.route('/run_...
Ari Victor
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

View additional questions