Questions tagged [falconframework]
A bare-metal Python web API framework for building very fast app backends and microservices.
191
questions
0
votes
0
answers
22
views
How to correctly change the location directive in nginx?
I implemented a simple REST API using Falcon and running it with Gunicorn. An example call looks like this
curl "http://localhost:5000/articles?limit=100"
Now I'm trying to make the API ...
0
votes
0
answers
59
views
Class variable is being cached?
I have strange issue that I'm having hard time to understand possibly based on how global or class variables work in python. I've a falcon class where i call rest api with a class design. I modify ...
0
votes
1
answer
271
views
Gunicorn + ThreadPoolExecutor: How to handle multiple simultaneous user requests?
I want to serve an falcon API that can handle multiple simultaneous user requests.
Each request triggers a long processing task therefore I used the ThreadPoolExecutor from concurrent.futures as ...
1
vote
1
answer
92
views
How can I intercept static routes in a falcon app?
I'm currently serving up files using a static route like so:
application.add_static_route('/artifacts/', '/artifacts/')
How can I add a function that is called before every GET to this route and any ...
1
vote
1
answer
83
views
Multiple parameters to falcon service
I have a falcon script that I am trying to pass multiple parameters to:
import falcon
import random
import os
import time
waitTime = int(os.environ.get('WAIT_TIME', '2'))
class SomeFunc(object):
...
0
votes
1
answer
124
views
Websockets with Falcon & Daphne behind a K8s Ingress
My Falcon based ASGI app is executed via Daphne and works fine when it is run locally and accessed via localhost. The app is packaged in a container and run in a K8s cluster behind an Ingress. On K8s ...
7
votes
1
answer
457
views
Selenium + Flask/Falcon in Python - 502 Bad Gateway Error
I'm using selenium to make a headless scraping of a website within an endpoint of an API using Flask for Python. I made several tests and my selenium scraping code works perfectly within a script and ...
0
votes
1
answer
114
views
Falcon server with SSL stops working after some hours/days
I set up a very basic Python API server with falcon along the example given in the documentation. And it seems to work just fine.
Now I extended the code to support HTTPS requests using SSL ...
0
votes
0
answers
106
views
Python falcon framework integration testing not working
I am pretty new to integration testing and falcon framework and having hard time to implement integration test for my apis. I have been trying to use sqllite to create a fixture data and use it ...
0
votes
0
answers
16
views
How To set X Frame Options in Python Falcon Application?
I have to set in my app X - Frame Options to prevent clickjacking, how to do this in Python Falcon framework? As far as I know it must be done on backend side, probably in falconapp.py
0
votes
1
answer
23
views
Why global site-package does not see a local one?
I install python package using the system package manager:
apk add py3-gunicorn
Then I create and fill venv with falcon:
python3 -mvenv --system-site-packages .
. ./bin/activate
pip3 install falcon
...
0
votes
1
answer
84
views
Python (falcon) transition is read only
I'm running into a strange error -psycopg2.errors.ReadOnlySqlTransaction: transaction is read-only when i'm trying to read data from my redshift database from my python application. I'm not trying to ...
2
votes
0
answers
139
views
Issues with Firebase Admin SDK on elastic beanstalk
Just to give a brief introduction, I am using elastic beanstalk from Amazon to deploy my python (Falcon) application. I have two environments of elastic beanstalk (one being the main app server and ...
1
vote
1
answer
204
views
How to route the client 'GET' request from one API to another another API with same end points using Falcon in python?
I have two APIs with same end points, but different URLs. Like this:
API_1 = /takeout/{t_note}
/serve/{t_note}/{m_note}
API_2 = /takeout/{t_note}
/serve/{t_note}/{m_note}
A client ...
0
votes
1
answer
118
views
python falcon falcon.before with async
I'm looking to add a falcon.before hook such as:
def check_authenticated(request, response, resource, params):
print(request.headers)
request.context.test = 'test'
@falcon.before(...
0
votes
1
answer
71
views
python Falcon changing domain name for Request URL
For an API I am writing in Falcon (python) I am trying to have the API hosted on a different domain name than localhost:8080. I want to be able to request at http://mydomainname rather than http://...
0
votes
1
answer
87
views
How to read an image sent in body of req in falcon
Sending jpg image in body of POST, using postman to do so:
Reading it with
image_text_similarity.py:
import json
class ImageTextSimilarity():
def on_post(self, req, resp):
image_raw = ...
1
vote
0
answers
119
views
How to transfer media stream from SocketSever to Falcon API with Python
I am developping a small python server that aims to receive a MP4 stream as a socket server and I want to transfer the data to another client that connect with a GET request with Falcon.
Here my API ...
0
votes
1
answer
271
views
Falcon API CPU intensive tasks
I'm trying to build a REST API using Falcon. I will have a post endpoint where i'll receive a json (sometimes with hundreds of keys) and i will attempt to process this data:
sanitize text data
...
1
vote
1
answer
107
views
GUnicorn and shared dictionary on REST API: "Ran out of input" Error on high load
I am using a manager.dict to synchronize some data between multiple workers of an API served with GUnicorn (with Meinheld workers). While this works fine for a few concurrent queries, it breaks when I ...
1
vote
1
answer
450
views
falcon api stream vs bounded_stream vs get_media
Could someone help me to understand the difference between the various methods:
request.bounded_stream.read()
request.stream.read()
request.get_media()
They seem to do the same thing, but using ...
1
vote
1
answer
364
views
"Missing 1 required positional argument: 'resp'" when invoking Falcon resource responder that has a 'self' argument
I am developing a WSGI application on Windows. I use peewee (which is supposedly unrelated) and:
falcon==2.0.0
waitress==1.4.3
I have the following code in my resources.py:
from models import Board
...
0
votes
1
answer
330
views
Combining a daemon with a REST API [closed]
I'm working on a daemon that I can run in a container which will continuously grab live data and feed it to redis to be consumed by other parties, and I have been intending to attach a REST API which ...
1
vote
1
answer
41
views
Get remaining part of the url (including slashes) in Falcon
In my Falcon app I would like to register a route like this:
app.add_route("/more_details/{some_id}", handler)
The problem is, that the part of some_id might contain an arbitrary number of slashes. ...
1
vote
1
answer
78
views
Has to be my code in Falcon resources thread-safe?
There are few thread-safety mentions in Falcon docs, but I'm still unsure whether or not my own code in resource responders (on_get(), on_post() etc.) have to be written in thread-safe manner.
I run ...
1
vote
1
answer
344
views
[Python][Javascript] can't figure out how to send API calls from a NEXTjs webpage GUI to a Python Falcon backend
I'm trying to send POST requests from a NEXTjs frontend with a simple form field to a backend located on the same server which is a python script using the Falcon library. The python script itself is ...
1
vote
0
answers
45
views
Is there a way to avoid falcon doubling the memory needed in Python?
I'm somewhat of a novice on Python, though have a solid understanding of other programming languages. We have a set of code that's using python but amounts to this.
def on_get(self, req, resp):
...
4
votes
1
answer
873
views
How to save an image from POST request with Falcon Python
I'm trying to find a way to save an image I get from a POST request, so far all the solutions I found ended up not working, for example, this.
The problem in which the above solution is that I just ...
3
votes
1
answer
659
views
Serve pdf file with Falcon RES API
I'm trying to serve a pdf file using Falcon REST API, but I can't find any example of it.
So far this is what I've tried:
class ReportResource:
def on_get(self, req, resp):
filename="./...
0
votes
1
answer
399
views
Two API's both using JWT authentication. How to authenticate between the two?
I have two rest API's using a Bearer auth header to a authenticate.
This works perfectly for the front-end of both systems, they call the auth endpoint, obtain a token and attach it for the duration ...
2
votes
2
answers
671
views
How to send body to simulate_post in Falcon
def test_with_invalid_param(self):
body = urlencode({
"email":"jit",
"password":"ewr"
})
result = self.simulate_post(self.path, body=body, headers=self....
0
votes
1
answer
158
views
Falcon, wsgiref : Unit test cases
I have the below code:
master.py
def create():
master = falcon.API(middleware=Auth())
msg = Message()
master.add_route('/message', msg)
master = create()
if __name__ == '__main__':
...
0
votes
1
answer
192
views
falcon-autocrud: how to handle unique rows?
I want to create a simple app with Falcon that is able to handle small sqlite database with hostname: ip records. I want to be able to replace rows in sqlite, so I decide that hostname is unique field....
0
votes
1
answer
177
views
Python WSGIREF: Kill the server on a condition
I have the below code:
from wsgiref import simple_server
import falcon
app = falcon.API(middleware=Auth())
msg = Something()
app.add_route('/hello', msg)
httpd = simple_server.make_server(127....
0
votes
1
answer
916
views
How to add HTTP_FORWARDED in logformat in uWSGI
I am referring - https://uwsgi-docs.readthedocs.io/en/latest/LogFormat.html
Default logformat is:
[pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(...
0
votes
1
answer
66
views
Sqlite :memory: visualizer
I'm using SQLite :memory: DB to test a Falcon API. On my POSTs, I'm creating entries on the DB (i know this because I have an endpoint to GET these entries which work great). I would like to know if ...
3
votes
1
answer
1k
views
How to we send a file (accepted as part of Multipart request) to MINIO object storage in python without saving the file in local storage?
I am trying to write an API in python (Falcon) to accept a file from multipart-form parameter and put the file in MINIO object storage. The problem is I want to send the file to Minio without saving ...
0
votes
1
answer
52
views
Returning HTTP responses from service without coupling to Falcon modules
I'm building my user service and am trying to decouple it from the API. When the user service encounters an error, it sets an error attribute on the service in the following format:
{
'message': '...
2
votes
0
answers
167
views
Gunicorn - exits the terminal automatically immediatly after running venv
When I run my gunicorn command in python venv, the terminal gets closed abruptly, without giving any message or error.
It is a sample python falcon api. I am able to run the api if I am not using the ...
0
votes
3
answers
481
views
ModuleNotFound errorin falcon
I am following the official falcon tutorial and there, they have used waitress-serve --port=8000 falcon.app:api to run the server. However, when I run this line in my terminal, it says
There was ...
1
vote
1
answer
2k
views
How to read raw json request from POST request in Falcon
How do I parse JSON request something like that?
{
"location_with_names": [
{
"location_id": 101,
"names": [
"a",
"b",
"c"
]
},
{
"...
1
vote
2
answers
581
views
Fetching boolean value from request
I am fetching a boolean value from the request in falcon API.
Sample url :
localhost:8080/api/some-end-point/101?something=true
I want
----------------------------------
| something | ...
0
votes
3
answers
189
views
Not able to import Python module
I am having a server and a testing module in falcon but I am not able to import the server module into the testing module when running the test cases.
This is my hierarchy:
project
|
--...
1
vote
0
answers
152
views
Python Falcon routes with simple functions?
Taking the following example from the getting started page.
Can I write my route handlers as simple functions?
Without classes, and class instances, member functions, self instance references?
# ...
0
votes
1
answer
288
views
Query to return all documents in which a field matches any element from a list in MongoEngine
I have two MongoDB collections. One is Users and another is Posts. In the user collection, each document stores a list of usernames that that particular user follows. For example,
{
'username' : '...
1
vote
0
answers
30
views
Not able to import name from root of the project
I am having a server.py file which is written in Falcon. Which looks like this.
try:
import falcon, logging
from os.path import dirname, realpath, join
from wsgiref import simple_server
...
1
vote
2
answers
760
views
How to get an .xlsx file from a Falcon resp.stream
I'm trying to get the generated .xlsx file from the API.
I have the following code on the back-end:
from io import BytesIO
from openpyxl import Workbook
@api_resource('/get_report')
class Report:
...
3
votes
2
answers
2k
views
How to generate Open API specification from existing falcon api?
I had an existing RESTful API written in Falcon framework. Currently, I used Sphinx for API documentation. I want to switch to Swagger (now called OpenAPI) and generating the Swagger Specification ...
0
votes
1
answer
908
views
How to start application in Falcon with Gunicorn
I have simple application,
# app.py
import falcon
class ThingsResource:
def on_get(self, req, resq) :
# something
class SomeResource:
def on_get(self, req, resq) :
# something
def ...
0
votes
0
answers
75
views
database mocking Python
I am writing test cases for a file called api.py and app.py instantiated my app.
app.py
from d import db
def create():
d = db()
# here I create db instance and pass to my application
...