Posts by Igor Cavalcanti • 478 points
18 posts
-
2
votes2
answers641
viewsA: When "Return" is different from "Return await" in an asynchronous function in Javascript?
The function shall be marked as async when there is an explicit call to a await within it. It can be freely marked as async when we want to run it asynchronously, even when it has no statement…
-
1
votes2
answers145
viewsA: Update commits to consider changes in . gitignore
git rm --cached <arquivo> removes the archive from the repository (git then stops trackear of that file), but it remains in its workspace. It is very common to use this command after adding a…
-
1
votes1
answer66
viewsA: loop for Jinj2 flask
There are two basic errors in its application. The first one is in relation to the nomenclature of the variables. In the excerpt {% for form in form %} you are naming the variable that goes through…
-
3
votes1
answer744
viewsA: How does the "extends" and "block endblock" commands of Jinja2 work?
The tags extends and block work together and serve to build templates with ideas of inheritance, overlapping and reuse. In a template you can define numerous tags block, which can later be…
-
0
votes1
answer154
viewsA: Error in tests with python 3.7, pytest and flask Blueprint
The error says that you are not in the context of the application when trying to generate the URL with the function url_for. In the fixture creation file on conftest.py you can instead of returning…
-
1
votes1
answer1508
viewsA: SQL Server Connection - Python
You can use the connection string this way: params_conn = 'Driver={{ODBC Driver 17 for SQL Server}};' \ 'Server={servidor}, {porta};' \ 'Database={base};' \ 'UID={usuario};' \ 'PWD={senha};' To…
-
1
votes1
answer713
viewsA: Git - Change commit message
Dude, I suggest you read the Git tutorial provided itself here. But basically, you will do the command git rebase -i HEAD~2 in the same way that you are currently doing, indicating that you wish to…
-
2
votes2
answers199
viewsA: How to reduce formula . replace in Python
Well, according to the documentation from pandas you can make the replacement directly across the DataFrame as follows (reference reference here): df = df.replace(["Sim", "Não"], [1, 0]) Note that…
-
2
votes2
answers54
viewsA: How to start waitress-server in Background?
With the following command: waitress-serve --call --listen=0.0.0.0:5000 app:create_app >> log.txt & This way, you redirect the log output to log.txt and & force run in the background.…
python-3.xanswered Igor Cavalcanti 478 -
1
votes5
answers4459
viewsA: Access dictionary within a Python list
You can iterate over the list elements as follows: for elm in cl_cadastrados: if nome == elm['nome']: ... This way you iterate on the elements of cl_cadastrados and access the elements directly.…
-
1
votes1
answer240
viewsA: How to correctly read a multi-level JSON?
The problem is in your test. You test item['DadosBasicosMateria']['ApelidoMateria'] if 'ApelidoMateria' in item else None This way you are checking whether ApelidoMateria this in item, when you…
-
1
votes1
answer139
viewsA: How to read a JSON with missing fields to fill in a dictionary?
Before filling the dictionary with the desired key you check if the key exists in JSON. That way: dicionario = { "DescricaoObjetivoProcesso": item["DescricaoObjetivoProcesso"] if…
-
1
votes1
answer55
viewsA: How to format specific links?
You can apply the style to classes, tags or id’s. To apply to classes, simply add the class to your tag with the attribute class="nome_da_classe". That way, the CSS looks like this: .nome_da_classe{…
-
2
votes1
answer661
viewsA: Define the execution period of an application
welcome! You can use the task scheduling library for python call schedule (documentation here). With it you can schedule the tasks to be performed, as well as organize the duration and sequence. You…
-
0
votes1
answer1600
viewsA: How to update content without reloading an HTML page?
Well, you really need to use something other than Flask himself for this task and Ajax is a good solution. However, the data update must occur given some event. Since you need a full-time update,…
-
1
votes2
answers154
viewsA: Flask and its contexts
What is Request Context? The context of the request (or request, English) appears when a request is made to your application. At this time, according to the documentation, a request context,…
-
1
votes1
answer149
viewsA: Circular import
Well, flask is intended to be completely modularized and free so that you feel free to define the best structure. One of the framework’s best practices is to work with the so-called "Application…
-
0
votes1
answer286
viewsA: Deploy flask application on Heroku with flask-sqlalchemy
You need to add the database add-on to your Heroku application (I confess I don’t understand much of it, but following this tutorial here…