sudo apt install xh
seems to be a thing
npm
, it would have been 3000 deps probably, so not there yet.
xh
wasn't much faster than httpie
, I guess outputting to a graphical terminal emulator is another bottleneck.)
hi everyone!
clarification question...
atm to edit a PostgreSQL field named special_attributes of type jsonb, I'm sending a param like
domain?special_attributes={
"id": "1a8b8863-a859-4d68-b63a-c466e554fd13",
"name": "Ada Lovelace",
"email": "me@adalovelace.com",
"bio": "First computer programmer.",
"age": 206,
"avatar": "http://en.wikipedia.org/wiki/File:Ada_lovelace.jpg"
}
Even though it works and the record is updated, I wouldn't like to be using req.param for this purpose...
What to use in such case?
@tiago-peres it is your API, and you can design it according to your liking, so I wouldn't go as harsh as saying "this is wrong (or right)" :slight_smile:
But typically in RESTful and REST-like HTTP APIs query parameters are used more for filtering, particularly in conjunction with idempotent, read-only requests such as GET
.
In order to modify a resource, it is more common to provide data in the request body. Assuming you have installed a media handler for the media type in question (JSON is supported out of the box), you can access it using req.get_media()
(or just req.media
, but beware it performs I/O upon first access).
special_attributes
as a JSON part, and use part.get_media()
.
Hello everyone,
I am new to Falcon and trying to transition from other frameworks such Flask or DJango.
I'm working on my first Falcon app after reviewing all of the tutorials and documentation I could find. However, as someone who is used to Flask's more object-oriented programming, I was wondering what would be your recommendations on the best method to create a Falcon async instance-based app, such as the one given in the Uvicorn documentation, rather than a function-based project as shown in the Falcon starting guide with the create_app() function.
Thank you in advance; best regards.
Hi @NoobInTheNet_gitlab!
The create_app()
function in that tutorial is merely a convenience wrapper around an "instance-based" app. In the same tutorial's code for create_app()
you'll find the familiar app = falcon.App()
, etc.
If you wish, feel free to subclass falcon.App
(or falcon.asgi.App
since you mentioned async). I often go that way when developing larger projects myself. Normal Python subclassing patterns apply in that case.
Hello @maxking:matrix.python-gsoc.org,
I highly appreciate your response, I deleted my reply to @vytas7 since I got some ideas to test before requesting for a full example, but I belive your example is more than enough to understand it.
Thank you both! :)
You're welcome @NoobInTheNet_gitlab.
As you can see, even Mailman's example has a convenience factory function in the form of make_application()
just below.
This is at times handy if your __init__()
takes parameters and/or you want to customize the app instance after creation, and you need a factory callable without parameters for your ASGI/WSGI server (but you want to reuse/customize the app differently in other contexts, e.g., the test suite, dev server and what not). Otherwise you can just the class directly.
I am using the falcon 3.1.0 framework for microservice development in my product. Also I am creating windows executable using pyinstaller 4.10. I can run microservice using gevent and also create windows executable using pyinstaller. While running the executable it failed to import the falcon submodule but for falcon 2.0 it works. It raises the following error. (accregisterenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps\dist>run_accountregistration\run_accountregistration.exe
Traceback (most recent call last):
File "run_accountregistration.py", line 9, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "app.py", line 6, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "falcon__init__.py", line 32, in <module>
File "falcon\app.py", line 22, in init falcon.app
ImportError: cannot import name app_helpers
[5848] Failed to execute script 'run_accountregistration' due to unhandled exception!
(accregisterenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps\dist>
Hi @smitasnaik!
Unfortunately I have no experience with pyinstaller
. @CaselIT have you ever used this one?
Does Falcon 2.0 work with the same project and the same version of pyinstaller
, or did it use to work at some point in the past?
One thing I can think of is that we have changed the build process to PEP 517, however, we still use setuptools
. Maybe that, in combination that we also build binary modules with Cython, confuses pyinstaller
somehow? Moreover, we started shipping binary wheels for Windows, maybe something is different there? Re PEP 517, could you try Falcon 3.0 for comparison?
Do you know more about how pyinstaller
works? Is it purely in memory, or does it extract files on disk? If you could get a snapshot of such a directory, maybe we could take a look at what's wrong there.
--no-binary
in pip install or downloading the source tar from pypi and installing it
I have tried this command raise following error even if install Microsoft Visual Studio 14.0
pip install falcon==3.1.0 --no-binary :all:
C:\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.c(11002): warning C4244: '=': conversion from 'Py_ssize_t' to 'long', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\MUM_DEV_TEAM\INSTALLER\PYTHON_39\PY39ENVS\accregenv\libs /LIBPATH:C:\Users\admin\AppData\Local\Programs\Python\Python39\libs /LIBPATH:C:\Users\admin\AppData\Local\Programs\Python\Python39 /LIBPATH:C:\MUM_DEV_TEAM\INSTALLER\PYTHON_39\PY39ENVS\accregenv\PCbuild\amd64 /LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64 /LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64 /LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64 /EXPORT:PyInit_Scanning build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.obj /OUT:build\lib.win-amd64-3.9\Cython\Compiler\Scanning.cp39-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.cp39-win_amd64.lib
Scanning.obj : warning LNK4197: export 'PyInit_Scanning' specified multiple times; using first specification
LINK : fatal error LNK1104: cannot open file 'build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-k63iwcod\cython_c9412625356b45e1a7ef2581a8b3f9f7\Cython\Compiler\Scanning.cp39-win_amd64.lib'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit code 1104
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Encountered error while trying to install package.
cython
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip
(accregenv) C:\MUM_DEV_TEAM\edcservices\accountregistration-ps>
Encountered error while trying to install package.
cython
@smitasnaik What do you get if you attempt to
pip install cython
?
Downloaded cython wheel from given link and execute following command
pip install Cython-0.29.30-py2.py3-none-any.whl --force-reinstall
Raise same error :
Scanning.obj : warning LNK4197: export 'PyInit_Scanning' specified multiple times; using first specification
LINK : fatal error LNK1104: cannot open file 'build\temp.win-amd64-3.9\Release\Users\admin\AppData\Local\Temp\pip-install-0l16xk1k\cython_daa866b856604001b70cf3c676f96c47\Cython\Compiler\Scanning.cp39-win_amd64.lib'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe' failed with exit code 1104
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Encountered error while trying to install package.
cython
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
@smitasnaik So could you try to find the file tree that pyinstaller
creates for Falcon, pack it as a Zip file, and upload to a new discussion?
(IIRC GitHub accepts up to 25 MiB .zip
files.)