Flask 1.0 Released 🎉
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/flask
https://redd.it/8f5yn9
https://www.palletsprojects.com/blog/flask-1-0-released/
/r/flask
https://redd.it/8f5yn9
How can I use Python to automate mass-printing in my office?
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks.
I work for a travel company, and I've recently been put in charge of admin duties which involve physically printing out customized cover letters and selected information sheets (dependent on which tour / location we're sending clients to, which airline they're flying with, transfer companies etc) to mail to our clients pre-departure. I have to spend a lot of time selecting the right documents to send them, and it's really eating up my time when this isn't really my job role.
The problem is, no one else is going to do it, so I'd love to find a way to automate it so I can free up time to do my actual job.
My current theory at the moment would be a basic spreadsheet with boolean values for each airlines, tour operators etc, cover letters, then make a basic loop that grabs the client name, customizes and populates the PDFs and then does a batch print job.
Can anyone suggest a better way to do this, or specific libraries to use, etc? Would love to hear your suggestions :)
Thanks all, and have a good day!
/r/Python
https://redd.it/8fa955
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks.
I work for a travel company, and I've recently been put in charge of admin duties which involve physically printing out customized cover letters and selected information sheets (dependent on which tour / location we're sending clients to, which airline they're flying with, transfer companies etc) to mail to our clients pre-departure. I have to spend a lot of time selecting the right documents to send them, and it's really eating up my time when this isn't really my job role.
The problem is, no one else is going to do it, so I'd love to find a way to automate it so I can free up time to do my actual job.
My current theory at the moment would be a basic spreadsheet with boolean values for each airlines, tour operators etc, cover letters, then make a basic loop that grabs the client name, customizes and populates the PDFs and then does a batch print job.
Can anyone suggest a better way to do this, or specific libraries to use, etc? Would love to hear your suggestions :)
Thanks all, and have a good day!
/r/Python
https://redd.it/8fa955
reddit
How can I use Python to automate mass-printing in my... • r/Python
Hi all! Like many of you, I have an office job with a lot of repetitive daily tasks. I work for a travel company, and I've recently been put in...
sqlalchemy query as dict
Is there a simple way to return the query result as a dict without much hassle?
I have this query: result = SomeModel.query.with_entities(....).filter(...).all(). With this I get the desired fields as a list. Now I would like to get them with their corresponding column name. Is it possible to do this in the query directly without additional computing? I have tried with label() and with_labels() but with no luck.
/r/flask
https://redd.it/8f3bom
Is there a simple way to return the query result as a dict without much hassle?
I have this query: result = SomeModel.query.with_entities(....).filter(...).all(). With this I get the desired fields as a list. Now I would like to get them with their corresponding column name. Is it possible to do this in the query directly without additional computing? I have tried with label() and with_labels() but with no luck.
/r/flask
https://redd.it/8f3bom
reddit
sqlalchemy query as dict • r/flask
Is there a simple way to return the query result as a dict without much hassle? I have this query: result =...
Strong password and passphrase generator package with entropy calculation
Hey, longtime lurker here. Finally decided to give developing new packages a shot and released a package for generating cryptographically strong passwords and passphrases. I still have a lot to learn so I appreciate any tips or comments on how to improve!
[SPass](https://github.com/Tauag/spass)
/r/Python
https://redd.it/8fby9a
Hey, longtime lurker here. Finally decided to give developing new packages a shot and released a package for generating cryptographically strong passwords and passphrases. I still have a lot to learn so I appreciate any tips or comments on how to improve!
[SPass](https://github.com/Tauag/spass)
/r/Python
https://redd.it/8fby9a
GitHub
Tauag/spass
spass - Generate cryptographically strong passwords and passphrases
Someone is scraping my website, what can I do to automatically block them?
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP addresses are scraping the data. I've been blocking the IP's but the scraper is now using 3+ IP addresses at a time to scrape.
What can I do to prevent the mad scrapes? Is there some way for my server to automatically ban an IP address if it hits too many impressions during a period of time?
/r/django
https://redd.it/8fcq91
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP addresses are scraping the data. I've been blocking the IP's but the scraper is now using 3+ IP addresses at a time to scrape.
What can I do to prevent the mad scrapes? Is there some way for my server to automatically ban an IP address if it hits too many impressions during a period of time?
/r/django
https://redd.it/8fcq91
reddit
Someone is scraping my website, what can I do to... • r/django
I run a real estate listings site and there is someone scraping the records one-by-one. I track each listing impression and I can see which IP...
SQLAlchemy vs PostgreSQL Functions
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries on the DB and then respond back the return from the Database.
Now a problem is that SQL is hard to read once it reaches a certain amount of complexity (and that can happen really fast). Production is very slow and the code becomes hard to maintain. On the other hand, one can argue that it's more performant than using a lightweight ORM like SQLAlchemy. Did any of you make similar experience? Would you let handle PostgreSQL everything, as we do, or would you move the logic to Flask?
I hope to read some advices.
Have a great weekend!
/r/flask
https://redd.it/8ff41v
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries on the DB and then respond back the return from the Database.
Now a problem is that SQL is hard to read once it reaches a certain amount of complexity (and that can happen really fast). Production is very slow and the code becomes hard to maintain. On the other hand, one can argue that it's more performant than using a lightweight ORM like SQLAlchemy. Did any of you make similar experience? Would you let handle PostgreSQL everything, as we do, or would you move the logic to Flask?
I hope to read some advices.
Have a great weekend!
/r/flask
https://redd.it/8ff41v
reddit
SQLAlchemy vs PostgreSQL Functions • r/flask
Hey guys, we're using heavily PostgreSQL (we let it handle all business logic, mapping, etc.). We use Flask only to handle requests, call queries...
Basic Docker (Compose) Django + Postgres Setup
https://www.youtube.com/watch?v=90LCcim-wHQ
/r/django
https://redd.it/8ff028
https://www.youtube.com/watch?v=90LCcim-wHQ
/r/django
https://redd.it/8ff028
YouTube
Dockerize your Django Application - Part 1/3
Part 2: https://www.youtube.com/watch?v=pStG1cmXzZo
Website: https://chkr.at
Docker-Compose Documentation: https://docs.docker.com/compose/overview/
Install Docker Tutorial: https://docs.docker.com/install/
Want to say thanks? Subscribe and Like my Videos…
Website: https://chkr.at
Docker-Compose Documentation: https://docs.docker.com/compose/overview/
Install Docker Tutorial: https://docs.docker.com/install/
Want to say thanks? Subscribe and Like my Videos…
A python multithreaded logging handler package that streams records to AWS services(S3, Kinesis)
https://github.com/omrikiei/aws_logging_handlers
/r/Python
https://redd.it/8ffvg8
https://github.com/omrikiei/aws_logging_handlers
/r/Python
https://redd.it/8ffvg8
GitHub
GitHub - omrikiei/aws_logging_handlers: AWS integration for python logging handlers(S3, Kinesis)
AWS integration for python logging handlers(S3, Kinesis) - omrikiei/aws_logging_handlers
Changing Matplotlib fonts: Neophyte who uses Juno Jupyter for scientific plotting.
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of plotting pretty data and performing analyses on it. But I’m stuck somewhere that while trivial, will nevertheless drive me nuts as a strongly visual person: If anyone could provide guidance for changing the font on either a global or per-plot basis for all labels and legends in a plot you would have my eternal gratitude. Using rcParams as in the matplotlib documentation gives:
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
/r/JupyterNotebooks
https://redd.it/8fbqru
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of plotting pretty data and performing analyses on it. But I’m stuck somewhere that while trivial, will nevertheless drive me nuts as a strongly visual person: If anyone could provide guidance for changing the font on either a global or per-plot basis for all labels and legends in a plot you would have my eternal gratitude. Using rcParams as in the matplotlib documentation gives:
/home/nbuser/anaconda3_501/lib/python3.6/site-packages/matplotlib/font_manager.py:1320: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans
(prop.get_family(), self.defaultFamily[fontext]))
/r/JupyterNotebooks
https://redd.it/8fbqru
reddit
Changing Matplotlib fonts: Neophyte who uses... • r/JupyterNotebooks
I know this may be a little more specialized to Matplotlib, as I’m one of those lowly matl*b to Python ship jumpers, for the purposes of...
[AF] Jinja macros and field formatting.
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators, etc. Like so:
_forms.html
{% macro render_field(field) %}
<hr class="forms">
{{ field.label }}
{% if field.flags.required %}
*
{% endif %}
<br>
{{ field(**kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="flash">{{ error }}</span><br>
{% endfor %}
{% endif %}
{% endmacro %}
template code:
{% from "_forms.html" import render_field %}
{% extends "base.html" %}
{{ render_field(form.search_by) }}
{{ render_field(form.search_term) }}
{% endblock %}
My question is this: is there any way to pass width/height values to the engine via the macros? If you simply declare the fields directly you can pass parameters to format the field, but these parameters break the macros.
template code:
{% extends "base.html" %}
{{ form.description.label }}{{ form.description(size="100") }}
{% endblock %}
/r/flask
https://redd.it/8fbeil
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators, etc. Like so:
_forms.html
{% macro render_field(field) %}
<hr class="forms">
{{ field.label }}
{% if field.flags.required %}
*
{% endif %}
<br>
{{ field(**kwargs)|safe }}
{% if field.errors %}
{% for error in field.errors %}
<span class="flash">{{ error }}</span><br>
{% endfor %}
{% endif %}
{% endmacro %}
template code:
{% from "_forms.html" import render_field %}
{% extends "base.html" %}
{{ render_field(form.search_by) }}
{{ render_field(form.search_term) }}
{% endblock %}
My question is this: is there any way to pass width/height values to the engine via the macros? If you simply declare the fields directly you can pass parameters to format the field, but these parameters break the macros.
template code:
{% extends "base.html" %}
{{ form.description.label }}{{ form.description(size="100") }}
{% endblock %}
/r/flask
https://redd.it/8fbeil
reddit
[AF] Jinja macros and field formatting. • r/flask
Within jinja2 templates I'm using a macro to render the fields in my forms. The macros handle all the formatting, label placement, validators,...
Rookie Question. I have a /static/ folder defined for image assests. However my dynamic Routes invalidate the static path.. Help?
Hey all,
So i use the following convention for loading assets.
<img src="static/img/dashboard_entries.png" alt="" />
However I just changed my dashboard route from:
@app.route('/dashboard/')
to
@app.route('/dashboard/<string:userID>/')
and now my image link doesn't work.
<img src="static/img/dashboard_entries.png" alt="" />
This is because it fully qualifies to:
http://127.0.0.1:5000/dashboard/19/static/img/dashboard_entries.png
instead of its previous:
http://127.0.0.1:5000/dashboard/static/img/dashboard_entries.png
How does one handle the use of dynamic routes and static assets in the static folder?
Thanks in advance.
Tim.
/r/flask
https://redd.it/8e9wia
Hey all,
So i use the following convention for loading assets.
<img src="static/img/dashboard_entries.png" alt="" />
However I just changed my dashboard route from:
@app.route('/dashboard/')
to
@app.route('/dashboard/<string:userID>/')
and now my image link doesn't work.
<img src="static/img/dashboard_entries.png" alt="" />
This is because it fully qualifies to:
http://127.0.0.1:5000/dashboard/19/static/img/dashboard_entries.png
instead of its previous:
http://127.0.0.1:5000/dashboard/static/img/dashboard_entries.png
How does one handle the use of dynamic routes and static assets in the static folder?
Thanks in advance.
Tim.
/r/flask
https://redd.it/8e9wia
reddit
r/flask - Rookie Question. I have a /static/ folder defined for image assests. However my dynamic Routes invalidate the static…
1 votes and 2 so far on reddit
How are you (regularly) deploying new Django projects?
I find myself spending 2\+ hours every time I want to deploy a new Django project. I've started using django\-cookie\-cutter which has made a big difference in development as I can use Docker \(and our other developers can therefore get set up much more easily\) but getting those projects deployed to a server is still a frustrating and tedious task. I use Linode and do everything manually per\-project \(add SSH keys, updates hosts, install docker, pull project set up\).
Would something like beanstalk help here? Any suggestions to help simplify this process? Do other people struggle with the time deployment takes?
/r/django
https://redd.it/8fiz89
I find myself spending 2\+ hours every time I want to deploy a new Django project. I've started using django\-cookie\-cutter which has made a big difference in development as I can use Docker \(and our other developers can therefore get set up much more easily\) but getting those projects deployed to a server is still a frustrating and tedious task. I use Linode and do everything manually per\-project \(add SSH keys, updates hosts, install docker, pull project set up\).
Would something like beanstalk help here? Any suggestions to help simplify this process? Do other people struggle with the time deployment takes?
/r/django
https://redd.it/8fiz89
reddit
How are you (regularly) deploying new Django projects? • r/django
I find myself spending 2\+ hours every time I want to deploy a new Django project. I've started using django\-cookie\-cutter which has made a big...
What exactly is caching and how do I add it to an app I have on heroku?
I have a data science type application where I am getting public information from FPDS and SAM gov't website. The site is currently on heroku.
I would like cache views so if a person is researching more than one company they can quickly go back to earlier pages without having to fetch the results from the database everytime.
Based on my limited knowledge that is what casheing does?
Second, I am looking at [flash-caching](https://flask-caching.readthedocs.io/en/latest/#) and it doesn't appear to be that difficult to implement to the route's I would like to cashe.
The question is on heroku, you wouldn't use `simplecashe` would you? Would you use a different cashe strategy? From the docs the `CASHE_TYPE` can be `simple`, `redis`, `memcached` and serveral more. On heroku would I need to store the cache on something like redis or can I store it in memory?
/r/flask
https://redd.it/8e4yj1
I have a data science type application where I am getting public information from FPDS and SAM gov't website. The site is currently on heroku.
I would like cache views so if a person is researching more than one company they can quickly go back to earlier pages without having to fetch the results from the database everytime.
Based on my limited knowledge that is what casheing does?
Second, I am looking at [flash-caching](https://flask-caching.readthedocs.io/en/latest/#) and it doesn't appear to be that difficult to implement to the route's I would like to cashe.
The question is on heroku, you wouldn't use `simplecashe` would you? Would you use a different cashe strategy? From the docs the `CASHE_TYPE` can be `simple`, `redis`, `memcached` and serveral more. On heroku would I need to store the cache on something like redis or can I store it in memory?
/r/flask
https://redd.it/8e4yj1
Blockchain Explained in 7 Python Functions
https://www.kdnuggets.com/2018/04/blockchain-explained-7-python-functions.html
/r/Python
https://redd.it/8fiftx
https://www.kdnuggets.com/2018/04/blockchain-explained-7-python-functions.html
/r/Python
https://redd.it/8fiftx
reddit
r/Python - Blockchain Explained in 7 Python Functions
36 votes and 1 so far on reddit
A tool to generate Jupyter notebooks programmatically
I recently found myself needing to generate many Jupyter notebooks in different directories, that were all very similar, save for a few differences in a variable name.
Hence, I decided to write a Python script that generates a Jupyter notebook from an input template:
https://github.com/ismailuddin/jupyter-nb-templater
Maybe it might be useful to somebody? Comments and suggestions welcome!
/r/IPython
https://redd.it/8fk8sz
I recently found myself needing to generate many Jupyter notebooks in different directories, that were all very similar, save for a few differences in a variable name.
Hence, I decided to write a Python script that generates a Jupyter notebook from an input template:
https://github.com/ismailuddin/jupyter-nb-templater
Maybe it might be useful to somebody? Comments and suggestions welcome!
/r/IPython
https://redd.it/8fk8sz
GitHub
ismailuddin/jupyter-nb-templater
jupyter-nb-templater - A tool for generating Python scripts to programmatically generate Jupyter notebooks.
How to create a count down timer on Django?
Hi guys,
I just started Django. Though it is really challenging but it is exciting.
I just wrote a little hello world web app and also a web app that displays time.
I want to get my hands dirty before I move on to the next topic.
I want to create a countdown timer on Django.
I don't know how to go about it and I need your help guys.
if you have any little project for beginners, pls I would love to read your suggestion as well.
/r/django
https://redd.it/8fkpb0
Hi guys,
I just started Django. Though it is really challenging but it is exciting.
I just wrote a little hello world web app and also a web app that displays time.
I want to get my hands dirty before I move on to the next topic.
I want to create a countdown timer on Django.
I don't know how to go about it and I need your help guys.
if you have any little project for beginners, pls I would love to read your suggestion as well.
/r/django
https://redd.it/8fkpb0
reddit
How to create a count down timer on Django? • r/django
Hi guys, I just started Django. Though it is really challenging but it is exciting. I just wrote a little hello world web app and also a web app...
The Forgotten Optional `else` in Python Loops
https://medium.com/@s16h/the-forgotten-optional-else-in-python-loops-90d9c465c830
/r/Python
https://redd.it/8fkbem
https://medium.com/@s16h/the-forgotten-optional-else-in-python-loops-90d9c465c830
/r/Python
https://redd.it/8fkbem
Medium
The Forgotten Optional `else` in Python Loops
In this post we’ll discuss Python’s for...else and while...else syntax, one of the most rarely used and misunderstood features in Python.
What is flask used for
Hi, I am currently learning flask but would like to know how exactly are flask applications used in software development of companies.
For instance if a company is using the MEAN stack, where do the flask applications come into play?
The tutorial for the flask framework illustrates its use as a web application. However if I only need it as a web server, do I need to care about the templates?
Thank you all in advance! I’m a beginner in software engineering and would like to have a fuller picture of how different frameworks come together in a company.
Edit: Grammar
/r/flask
https://redd.it/8e7yli
Hi, I am currently learning flask but would like to know how exactly are flask applications used in software development of companies.
For instance if a company is using the MEAN stack, where do the flask applications come into play?
The tutorial for the flask framework illustrates its use as a web application. However if I only need it as a web server, do I need to care about the templates?
Thank you all in advance! I’m a beginner in software engineering and would like to have a fuller picture of how different frameworks come together in a company.
Edit: Grammar
/r/flask
https://redd.it/8e7yli
reddit
What is flask used for • r/flask
Hi, I am currently learning flask but would like to know how exactly are flask applications used in software development of companies. For...
How to prevent a customer from adding items just before the Confirm Payment button is clicked?
First, I am sorry I post it here because r/webdev is all about frontend, and r/backend is empty.
Currently I am working on an ecommerce project based on django-oscar. Since its accompanying paypal integration library is abandoned(and it's a two-step checkout), I decided to use BrainTree SDK to implement Paypal Express Checkout. Paypal EC gives you a button on the final review page that customer can click to have a pop-up window that they can login to paypal and pay.
The problem is, on the review page, the button needs a pre-determined checkout amount. That means when the page is generated, it has to fill in the button with the amount in the cart. If the customer add items after the review page is loaded but before clicking the button, the checkouted cart will have more items than those are paid.
I know django-oscar has a "freeze basket" function. But it will remove all items from the cart. I think a good place to call it would be during the review page generation. But I can't think of a reliable way to determine whether and when to restore the cart if the customer stops at review page and decides to checkout later, which I think would happen quite a lot.
Thanks for your help!
/r/django
https://redd.it/8fk1c1
First, I am sorry I post it here because r/webdev is all about frontend, and r/backend is empty.
Currently I am working on an ecommerce project based on django-oscar. Since its accompanying paypal integration library is abandoned(and it's a two-step checkout), I decided to use BrainTree SDK to implement Paypal Express Checkout. Paypal EC gives you a button on the final review page that customer can click to have a pop-up window that they can login to paypal and pay.
The problem is, on the review page, the button needs a pre-determined checkout amount. That means when the page is generated, it has to fill in the button with the amount in the cart. If the customer add items after the review page is loaded but before clicking the button, the checkouted cart will have more items than those are paid.
I know django-oscar has a "freeze basket" function. But it will remove all items from the cart. I think a good place to call it would be during the review page generation. But I can't think of a reliable way to determine whether and when to restore the cart if the customer stops at review page and decides to checkout later, which I think would happen quite a lot.
Thanks for your help!
/r/django
https://redd.it/8fk1c1
reddit
r/django - How to prevent a customer from adding items just before the Confirm Payment button is clicked?
4 votes and 3 so far on reddit