[Ask Flask] Adding a news section to an existing website?
Hi,
I've been working on a website for a school club and I chose to use flask as the framework.
So far everything looks very good and I'm learning a lot. However, I'm stuck on how to implement a "news" section where I can easily add/remove articles from the page. Sorta like a blog section.
I've looked at flask frozen and I really like the idea of statically generating the website but can't seem to find a good reference/tutorial on how to implement it. I also looked into lektor but it doesn't seem to support python 3, which is what I've been using.
I'm looking for any advice/help/tutorials if anyone has an idea of how I can approach this, thanks!
/r/flask
https://redd.it/5lj1js
Hi,
I've been working on a website for a school club and I chose to use flask as the framework.
So far everything looks very good and I'm learning a lot. However, I'm stuck on how to implement a "news" section where I can easily add/remove articles from the page. Sorta like a blog section.
I've looked at flask frozen and I really like the idea of statically generating the website but can't seem to find a good reference/tutorial on how to implement it. I also looked into lektor but it doesn't seem to support python 3, which is what I've been using.
I'm looking for any advice/help/tutorials if anyone has an idea of how I can approach this, thanks!
/r/flask
https://redd.it/5lj1js
reddit
[Ask Flask] Adding a news section to an existing website? • /r/flask
Hi, I've been working on a website for a school club and I chose to use flask as the framework. So far everything looks very good and I'm...
Poesy - Corpus-based Poetry Generation
https://github.com/anfederico/Poesy
/r/Python
https://redd.it/5m6ud2
https://github.com/anfederico/Poesy
/r/Python
https://redd.it/5m6ud2
GitHub
anfederico/Poesy
Poetry generation via natural language markov models - anfederico/Poesy
PyCharm working on ssh agent remote interpreter support for next release.
https://twitter.com/DmitryTrofimov/status/816998293897179136
/r/Python
https://redd.it/5m830f
https://twitter.com/DmitryTrofimov/status/816998293897179136
/r/Python
https://redd.it/5m830f
Twitter
Dmitry Trofimov
@BecomeInfinite Hi, yes we are planning to work on it for the next release. Vote to be notified about progress: https://t.co/WXhN55wIaP
[AF] My app is slow (9.9s to respond to query). What am I doing wrong?
I'm currently running a Flask app in Docker. It's slow- calls to my `/overview`
endpoint take ~9s (9925ms). I've run [profiling](http://imgur.com/a/9WCfu) and I'm pretty
stumped on how to proceed.
The code for my application is on Github as a
[gist](https://gist.github.com/finbarrtimbers/3426f7b29bc6d7f6d10d20bd4b15d48a).
Based on the profiling, it seems like there are three main bottlenecks:
1. The 2x calls to `_socket.getaddrinfo` (52.93%)
2. the 1134 calls to `method read of _ssl_SSLSocket` (16.46%)
3. the 2x queries (13.87%)
I assume that the queries (#3) are slow because my SQL is slow, so I'll work on
speeding that up separately. For #2, I assume I need to figure out how to call
the read method fewer times, so I also know how to proceed there.
However, what seems to be really killing me are the two
calls to `_socket.getaddrinfo`. How can I speed those up?
I've tried to Google this, but the [answers](http://stackoverflow.com/questions/17239840/find-bottleneck-of-flask-application)
that I've seen are all based on the assumption that the problem is transient,
and so changing your DNS settings will fix it.
Finally, I've been trying to set up a test case that will make this more
obvious to solve with cProfile (e.g. I want to be able to profile the function
call directly to isolate my problem, as done in the linked answer). However,
I can't find a way to log the arguments of all function calls so that I can
replicate them exactly. Is there a way to do this? I would like to log the
exact arguments passed to `socket.getaddrinfo` so I can isolate that and work
with it directly.
I would appreciate any advice on how to fix this, or any advice on my code in
general. Even a pointer to a book or article I could read would be super
helpful. Thanks in advance.
/r/flask
https://redd.it/5m8naz
I'm currently running a Flask app in Docker. It's slow- calls to my `/overview`
endpoint take ~9s (9925ms). I've run [profiling](http://imgur.com/a/9WCfu) and I'm pretty
stumped on how to proceed.
The code for my application is on Github as a
[gist](https://gist.github.com/finbarrtimbers/3426f7b29bc6d7f6d10d20bd4b15d48a).
Based on the profiling, it seems like there are three main bottlenecks:
1. The 2x calls to `_socket.getaddrinfo` (52.93%)
2. the 1134 calls to `method read of _ssl_SSLSocket` (16.46%)
3. the 2x queries (13.87%)
I assume that the queries (#3) are slow because my SQL is slow, so I'll work on
speeding that up separately. For #2, I assume I need to figure out how to call
the read method fewer times, so I also know how to proceed there.
However, what seems to be really killing me are the two
calls to `_socket.getaddrinfo`. How can I speed those up?
I've tried to Google this, but the [answers](http://stackoverflow.com/questions/17239840/find-bottleneck-of-flask-application)
that I've seen are all based on the assumption that the problem is transient,
and so changing your DNS settings will fix it.
Finally, I've been trying to set up a test case that will make this more
obvious to solve with cProfile (e.g. I want to be able to profile the function
call directly to isolate my problem, as done in the linked answer). However,
I can't find a way to log the arguments of all function calls so that I can
replicate them exactly. Is there a way to do this? I would like to log the
exact arguments passed to `socket.getaddrinfo` so I can isolate that and work
with it directly.
I would appreciate any advice on how to fix this, or any advice on my code in
general. Even a pointer to a book or article I could read would be super
helpful. Thanks in advance.
/r/flask
https://redd.it/5m8naz
Imgur
Imgur: The most awesome images on the Internet
Imgur: The most awesome images on the Internet.
The Reality of Developer Burnout
https://www.kennethreitz.org/essays/the-reality-of-developer-burnout
/r/Python
https://redd.it/5m8ezj
https://www.kennethreitz.org/essays/the-reality-of-developer-burnout
/r/Python
https://redd.it/5m8ezj
Ken Reitz
Essays Ken Reitz
Burnout is, unfortunately, a very real phenomenon in software development — especially when creating and maintaining open source projects with large numbers of users. I've experienced it, and I wanted to share my personal experience with the subject. It…
[P] TensorKart: self-driving MarioKart with TensorFlow
http://kevinhughes.ca/blog/tensor-kart?utm_source=SitePoint&utm_medium=email&utm_campaign=Versioning
/r/MachineLearning
https://redd.it/5m7zsa
http://kevinhughes.ca/blog/tensor-kart?utm_source=SitePoint&utm_medium=email&utm_campaign=Versioning
/r/MachineLearning
https://redd.it/5m7zsa
www.kevinhughes.ca
TensorKart: self-driving MarioKart with TensorFlow
Kevin Hughes' blog
Bayesian Modeling practice problems/projects?
Hi, I have a fairly rudimentary understanding of statistics and I'd like to improve my bayesian reasoning beginning with modeling. Its not hard for me to find papers and tutorials on the subject, but I really miss the days where I could have a list of problems that I try to work through and check my answers in the back of a book.
I'm not sure if bayesian modeling lends itself to that sort of framework at all (when I say rudimentary understanding of stat I mean it), but if anyone can point me in the right direction I would appreciate it.
/r/pystats
https://redd.it/5m8eda
Hi, I have a fairly rudimentary understanding of statistics and I'd like to improve my bayesian reasoning beginning with modeling. Its not hard for me to find papers and tutorials on the subject, but I really miss the days where I could have a list of problems that I try to work through and check my answers in the back of a book.
I'm not sure if bayesian modeling lends itself to that sort of framework at all (when I say rudimentary understanding of stat I mean it), but if anyone can point me in the right direction I would appreciate it.
/r/pystats
https://redd.it/5m8eda
reddit
Bayesian Modeling practice problems/projects? • /r/pystats
Hi, I have a fairly rudimentary understanding of statistics and I'd like to improve my bayesian reasoning beginning with modeling. Its not hard...
Flask-WTF 0.14 released with WTForms 2 Form.Meta support, better CSRF errors, and more
I've just released Flask-WTF 0.14 to PyPI. [You can read the changelog here](http://flask-wtf.readthedocs.io/en/stable/changelog.html#version-0-14).
Install or upgrade using pip: `pip install -U flask-wtf`
- [PyPI](https://pypi.python.org/pypi/Flask-WTF)
- [GitHub](https://github.com/lepture/flask-wtf)
- [Docs](https://flask-wtf.readthedocs.io/en/stable/)
This release, along with 0.13, makes some major changes and deprecations. Some of the changes may break your code if you're using some of the less common parts directly. Be sure to read the changelog carefully and test your code when you upgrade.
Major changes include:
- Switch from the deprecated WTForms `SecureForm` to the new `Form.Meta` system.
- Use itsdangerous to generate CSRF tokens.
- CSRF errors are more specifc and are logged as well as returned.
Please give it a try and provide feedback. I want to get the project down to 0 open issues and a 1.0 release soon. Any help in the form of bug reports and patches is appreciated!
/r/flask
https://redd.it/5madnr
I've just released Flask-WTF 0.14 to PyPI. [You can read the changelog here](http://flask-wtf.readthedocs.io/en/stable/changelog.html#version-0-14).
Install or upgrade using pip: `pip install -U flask-wtf`
- [PyPI](https://pypi.python.org/pypi/Flask-WTF)
- [GitHub](https://github.com/lepture/flask-wtf)
- [Docs](https://flask-wtf.readthedocs.io/en/stable/)
This release, along with 0.13, makes some major changes and deprecations. Some of the changes may break your code if you're using some of the less common parts directly. Be sure to read the changelog carefully and test your code when you upgrade.
Major changes include:
- Switch from the deprecated WTForms `SecureForm` to the new `Form.Meta` system.
- Use itsdangerous to generate CSRF tokens.
- CSRF errors are more specifc and are logged as well as returned.
Please give it a try and provide feedback. I want to get the project down to 0 open issues and a 1.0 release soon. Any help in the form of bug reports and patches is appreciated!
/r/flask
https://redd.it/5madnr
I used Python to help increase our month to month sales
https://jackstouffer.com/blog/target-predictable-customers.html
/r/Python
https://redd.it/5m87b6
https://jackstouffer.com/blog/target-predictable-customers.html
/r/Python
https://redd.it/5m87b6
Jackstouffer
Use Machine Learning To Increase The Sales From Your Predictable Customers
With machine learning, we can look at the buying patterns of our customers to target customers that can yeild more sales
I built a Django-powered job board/aggregator for remote Python jobs (x-post on /r/python)
Hi guys,
I just launched https://www.RemotePython.com a few days ago (built in Python of course, with Django). I started the project as I'm a freelance Python developer and only work remotely, and thought it would be nice if there's a site that only lists remote Python jobs as that would save people time from having to check/subscribe to multiple sites.
Right now, I'm doing the job postings manually. I have a list of sites that I check daily. I make sure that the job actually involves Python before posting it as sometimes you'll see postings like "we're a Java shop, but we'd also consider candidates who have experience in Python, etc.", and they get tagged as "python" because it appeared in the text.
I hope some of you will find the site useful and any feedback is appreciated!
P.S. For those curious about the tech stack:
- Python 3.5
- Django 1.10
- PostgreSQL 9.6
- Ubuntu 14.04
- Nginx
- Gunicorn
- Bootstrap 3
- jQuery
/r/django
https://redd.it/5mbji3
Hi guys,
I just launched https://www.RemotePython.com a few days ago (built in Python of course, with Django). I started the project as I'm a freelance Python developer and only work remotely, and thought it would be nice if there's a site that only lists remote Python jobs as that would save people time from having to check/subscribe to multiple sites.
Right now, I'm doing the job postings manually. I have a list of sites that I check daily. I make sure that the job actually involves Python before posting it as sometimes you'll see postings like "we're a Java shop, but we'd also consider candidates who have experience in Python, etc.", and they get tagged as "python" because it appeared in the text.
I hope some of you will find the site useful and any feedback is appreciated!
P.S. For those curious about the tech stack:
- Python 3.5
- Django 1.10
- PostgreSQL 9.6
- Ubuntu 14.04
- Nginx
- Gunicorn
- Bootstrap 3
- jQuery
/r/django
https://redd.it/5mbji3
Remote Python
Find remote Python jobs and developers.
Job board and aggregator for remote Python jobs and only remote Python jobs. Also a place to find remote Python developers. Sign up today to post jobs, create and publish your own profile, save job postings and add notes to them, and receive messages from…
Help needed to create app similar to IFTTT
I am trying to emulate the workflow of IFTTT on one of my work. The app will be consuming natural event data like Earthquake, Hurricane, etc. Users can subscribe on those events based on some rule like IFTTT e.g. User1 (U1) subscribes on Earthquake with magnitude >4 and User2 (U2) subscribes on magnitude >5. Based on this, if an earthquake with magnitude of 6 occurs, U1 and U2 should be notified. If it happens to be magnitude 4.5, only U1 should be notified. I am planning to do this in Django using MongoDB + PostgreSQL. My approach is something like this: Save rules for each user in MongoDB. Once an event occurs, find users who are subscribed on it and if the rule matches, fire a notification. Is there any better way to solve this problem? Any help is appreciated. Thanks.
/r/django
https://redd.it/5mc2qv
I am trying to emulate the workflow of IFTTT on one of my work. The app will be consuming natural event data like Earthquake, Hurricane, etc. Users can subscribe on those events based on some rule like IFTTT e.g. User1 (U1) subscribes on Earthquake with magnitude >4 and User2 (U2) subscribes on magnitude >5. Based on this, if an earthquake with magnitude of 6 occurs, U1 and U2 should be notified. If it happens to be magnitude 4.5, only U1 should be notified. I am planning to do this in Django using MongoDB + PostgreSQL. My approach is something like this: Save rules for each user in MongoDB. Once an event occurs, find users who are subscribed on it and if the rule matches, fire a notification. Is there any better way to solve this problem? Any help is appreciated. Thanks.
/r/django
https://redd.it/5mc2qv
reddit
Help needed to create app similar to IFTTT • /r/django
I am trying to emulate the workflow of IFTTT on one of my work. The app will be consuming natural event data like Earthquake, Hurricane, etc....
Visualize your trip with Flask and Mapbox
http://kazuar.github.io/visualize-trip-with-flask-and-mapbox/
/r/Python
https://redd.it/5mbblh
http://kazuar.github.io/visualize-trip-with-flask-and-mapbox/
/r/Python
https://redd.it/5mbblh
reddit
Visualize your trip with Flask and Mapbox • /r/Python
9 points and 0 comments so far on reddit
Passing invalid form with errors to another view?
If view 1's form POST's to view 2, and view 2 handles the form data (ex: validation, using form data to change database, etc.), but then you want to re-render view 1's template with form errors in the case of invalid data... What useful solutions exist? Besides Javascript and handling (I'd like to know if there is a conventional server side solution).
I'm thinking re-direction is necessary, otherwise rendering the old template from view 2 will require repeating tons of logic.
I considered using sessions to pass the form data back to view 1, and have view 1 check the session for form data before creating a new form to render, but am wondering if there's a simpler way.
Thanks!
/r/djangolearning
https://redd.it/5mbhlj
If view 1's form POST's to view 2, and view 2 handles the form data (ex: validation, using form data to change database, etc.), but then you want to re-render view 1's template with form errors in the case of invalid data... What useful solutions exist? Besides Javascript and handling (I'd like to know if there is a conventional server side solution).
I'm thinking re-direction is necessary, otherwise rendering the old template from view 2 will require repeating tons of logic.
I considered using sessions to pass the form data back to view 1, and have view 1 check the session for form data before creating a new form to render, but am wondering if there's a simpler way.
Thanks!
/r/djangolearning
https://redd.it/5mbhlj
reddit
Passing invalid form with errors to another view? • /r/djangolearning
If view 1's form POST's to view 2, and view 2 handles the form data (ex: validation, using form data to change database, etc.), but then you want...
psync - sync files to remote server with ease; feedback / PR appreciated
https://github.com/lazywei/psync
/r/Python
https://redd.it/5mddww
https://github.com/lazywei/psync
/r/Python
https://redd.it/5mddww
GitHub
lazywei/psync
psync - Synchronize project based on rsync
[Help] An email listener of sorts
I'd like to set up a self-hosted email address. It won't be used for sending email, just and end-point to receive an email and then process it with a python script. From there it will be able to use the parsed data to do things like push rich notifications, etc.
Where I'm stuck, is the world of email. Can anyone point me to the easiest solution to this on Ubuntu?
/r/Python
https://redd.it/5mbukv
I'd like to set up a self-hosted email address. It won't be used for sending email, just and end-point to receive an email and then process it with a python script. From there it will be able to use the parsed data to do things like push rich notifications, etc.
Where I'm stuck, is the world of email. Can anyone point me to the easiest solution to this on Ubuntu?
/r/Python
https://redd.it/5mbukv
reddit
[Help] An email listener of sorts • /r/Python
I'd like to set up a self-hosted email address. It won't be used for sending email, just and end-point to receive an email and then process it...
[Ask Flask] Using Flask alongside an apache server
Hello there /r/flask,
so I am building a web application which is served by an apache server on my raspberry.
Flask is running on the same server, but a different port (5000).
If I try to make a GET request with JQuery, there is a "Cross-Origin Request Blocked" in JavaScript, due to flask running on a different port than the apache server.
*if you have ideas on how to improve the setup (i.e. not using an apache server) please share those too.*
**How would you go about solving this?**
/r/flask
https://redd.it/5md1wq
Hello there /r/flask,
so I am building a web application which is served by an apache server on my raspberry.
Flask is running on the same server, but a different port (5000).
If I try to make a GET request with JQuery, there is a "Cross-Origin Request Blocked" in JavaScript, due to flask running on a different port than the apache server.
*if you have ideas on how to improve the setup (i.e. not using an apache server) please share those too.*
**How would you go about solving this?**
/r/flask
https://redd.it/5md1wq
reddit
[Ask Flask] Using Flask alongside an apache server • /r/flask
Hello there /r/flask, so I am building a web application which is served by an apache server on my raspberry. Flask is running on the same...
Need help! Python script for geocoding!
The below code was given to me by a DBA who was let go. My knowledge with python is quite basic, so I'm hoping this sub can help. I really appreciate any help!!!
My issues:
1. I'm not sure exactly how he ran the file.
2. Where do I put the .py file and the addresses.txt file? Same folder?
Here is a sample of the addresses.txt file:
1,16088+San+Pedro+Ave.+San+Antonio,+TX+78232
2,10811+Town+Center+Dr+San+Antonio,+TX+78251
3,25615+N.+US+Hwy+281+San+Antonio,+TX+78258
4,8230+N.+Loop+1604+W.+San+Antonio,+TX+78249
And now the code: [Pastebin Link](http://pastebin.com/Mk5XUXd1)
import urllib, json
from urllib import request
uid=""
address=""
f=open("addresses.txt","r")
fo=open("latlng.txt","w")
for row in f:
uid=row.split(",",1)[0]
address=row.split(",",1)[1].replace("\n","")
myurl = "https://maps.googleapis.com/maps/api/geocode/json?address=" +address +"&key=MY_KEY_HERE"
try:
googleResponse = request.urlopen(myurl)
jsonResponse=json.loads(googleResponse.read().decode("utf-8"))
lat=jsonResponse["results"][0]["geometry"]["location"]["lat"]
lng=jsonResponse["results"][0]["geometry"]["location"]["lng"]
fo.write(str(uid)+"|"+str(lat)+"|"+str(lng)+"\n")
except Exception as e:
print(uid,address,e)
pass
f.close()
fo.close()
Edit: code formatting
/r/Python
https://redd.it/5memtv
The below code was given to me by a DBA who was let go. My knowledge with python is quite basic, so I'm hoping this sub can help. I really appreciate any help!!!
My issues:
1. I'm not sure exactly how he ran the file.
2. Where do I put the .py file and the addresses.txt file? Same folder?
Here is a sample of the addresses.txt file:
1,16088+San+Pedro+Ave.+San+Antonio,+TX+78232
2,10811+Town+Center+Dr+San+Antonio,+TX+78251
3,25615+N.+US+Hwy+281+San+Antonio,+TX+78258
4,8230+N.+Loop+1604+W.+San+Antonio,+TX+78249
And now the code: [Pastebin Link](http://pastebin.com/Mk5XUXd1)
import urllib, json
from urllib import request
uid=""
address=""
f=open("addresses.txt","r")
fo=open("latlng.txt","w")
for row in f:
uid=row.split(",",1)[0]
address=row.split(",",1)[1].replace("\n","")
myurl = "https://maps.googleapis.com/maps/api/geocode/json?address=" +address +"&key=MY_KEY_HERE"
try:
googleResponse = request.urlopen(myurl)
jsonResponse=json.loads(googleResponse.read().decode("utf-8"))
lat=jsonResponse["results"][0]["geometry"]["location"]["lat"]
lng=jsonResponse["results"][0]["geometry"]["location"]["lng"]
fo.write(str(uid)+"|"+str(lat)+"|"+str(lng)+"\n")
except Exception as e:
print(uid,address,e)
pass
f.close()
fo.close()
Edit: code formatting
/r/Python
https://redd.it/5memtv
Pastebin
[Python] import urllib, json from urllib import request uid="" address="" f=open( - Pastebin.com
One annoying thing about Django
long time flask user, everytime i want to start django this one thing annoys me and i end up leaving django.
i usually create a dir, then go into that dir and create env, install django via pip, then create project and then create app. result is this awful looking dir structure for a single app site. doesnt anyone else find this annoying?
projectname/
env/
projectname/
projectname/...
projectnameapp/...
manage.py
ideally i would like this:
projectname/
env/
manage.py
projectname/
appname/
how? or why not?
/r/django
https://redd.it/5mf5sd
long time flask user, everytime i want to start django this one thing annoys me and i end up leaving django.
i usually create a dir, then go into that dir and create env, install django via pip, then create project and then create app. result is this awful looking dir structure for a single app site. doesnt anyone else find this annoying?
projectname/
env/
projectname/
projectname/...
projectnameapp/...
manage.py
ideally i would like this:
projectname/
env/
manage.py
projectname/
appname/
how? or why not?
/r/django
https://redd.it/5mf5sd
reddit
One annoying thing about Django • /r/django
long time flask user, everytime i want to start django this one thing annoys me and i end up leaving django. i usually create a dir, then go into...
What I Learned Implementing a Classifier from Scratch in Python
http://www.jeannicholashould.com/what-i-learned-implementing-a-classifier-from-scratch.html
/r/Python
https://redd.it/5mf2y1
http://www.jeannicholashould.com/what-i-learned-implementing-a-classifier-from-scratch.html
/r/Python
https://redd.it/5mf2y1
reddit
What I Learned Implementing a Classifier from Scratch... • /r/Python
4 points and 0 comments so far on reddit
Hyperparameter optimization for Neural Networks
http://neupy.com/2016/12/17/hyperparameter_optimization_for_neural_networks.html
/r/Python
https://redd.it/5mf28l
http://neupy.com/2016/12/17/hyperparameter_optimization_for_neural_networks.html
/r/Python
https://redd.it/5mf28l
Neupy
Hyperparameter optimization for Neural Networks — NeuPy
NeuPy is a Python library for Artificial Neural Networks. NeuPy supports many different types of Neural Networks from a simple perceptron to deep learning models.