KivEnt 2.2 Released (Python-Kivy 2d Game Engine)
http://chaosbuffalogames.com/blog/kivent-22-released.html
/r/Python
https://redd.it/5l6zbs
http://chaosbuffalogames.com/blog/kivent-22-released.html
/r/Python
https://redd.it/5l6zbs
reddit
KivEnt 2.2 Released (Python-Kivy 2d Game Engine) • /r/Python
23 points and 0 comments so far on reddit
Did you know you can use Jupyter in VSCode?
https://github.com/DonJayamanne/pythonVSCode/wiki/Jupyter-Examples
/r/Python
https://redd.it/5l4rl4
https://github.com/DonJayamanne/pythonVSCode/wiki/Jupyter-Examples
/r/Python
https://redd.it/5l4rl4
GitHub
DonJayamanne/pythonVSCode
pythonVSCode - This extension is now maintained in the Microsoft fork.
Mark Zuckerberg recommending Python
I was reading through this article on "Building Jarvis" by Mark Zuckerberg. Though the title pic is full of non Python code ( I think it is Perl or is it PHP?) that was a let down, this is a overall fantastic work, which he says he has coded in Python, ObjC & PHP.
https://www.facebook.com/notes/mark-zuckerberg/building-jarvis/10154361492931634
In the comments section though I saw this which is very important.
Mark Brady: This is fantastic! In one of your comments, you said, "No regrets. Let's just make sure we teach our children to code!". My son is very interested in coding and asked me for a book for beginners. In order to "future proof" his capabilities (if there are any..?), what language(s) should he focus? What's good for getting his confidence?
Like · Reply · 145 · December 19 at 11:41pm
Mark Zuckerberg: I think Python is a safe bet.
Unlike · Reply · 1,038 · December 20 at 12:18pm
/r/Python
https://redd.it/5l9om5
I was reading through this article on "Building Jarvis" by Mark Zuckerberg. Though the title pic is full of non Python code ( I think it is Perl or is it PHP?) that was a let down, this is a overall fantastic work, which he says he has coded in Python, ObjC & PHP.
https://www.facebook.com/notes/mark-zuckerberg/building-jarvis/10154361492931634
In the comments section though I saw this which is very important.
Mark Brady: This is fantastic! In one of your comments, you said, "No regrets. Let's just make sure we teach our children to code!". My son is very interested in coding and asked me for a book for beginners. In order to "future proof" his capabilities (if there are any..?), what language(s) should he focus? What's good for getting his confidence?
Like · Reply · 145 · December 19 at 11:41pm
Mark Zuckerberg: I think Python is a safe bet.
Unlike · Reply · 1,038 · December 20 at 12:18pm
/r/Python
https://redd.it/5l9om5
reddit
Mark Zuckerberg recommending Python • /r/Python
I was reading through this article on "Building Jarvis" by Mark Zuckerberg. Though the title pic is full of non Python code ( I think it is Perl...
How to implement a rating system?
I want to implement a rating system on my webapp in which users can rate the service of restaurants.
The problem : How can I ensure that users don't abuse the rating? e. g: giving 5 stars to one of their family members who owns the restaurant.
The backend is developed with Django.
Greetings from Germany
/r/django
https://redd.it/5l97ft
I want to implement a rating system on my webapp in which users can rate the service of restaurants.
The problem : How can I ensure that users don't abuse the rating? e. g: giving 5 stars to one of their family members who owns the restaurant.
The backend is developed with Django.
Greetings from Germany
/r/django
https://redd.it/5l97ft
reddit
How to implement a rating system? • /r/django
I want to implement a rating system on my webapp in which users can rate the service of restaurants. The problem : How can I ensure that users...
A small Guide to help you install Scikit-Learn and Get Started with Machine Learning on Linux
https://techarena51.com/index.php/getting-started-machine-learning-linux-python-3-scikit-learn/?utm_source=r-python
/r/Python
https://redd.it/5l9gtg
https://techarena51.com/index.php/getting-started-machine-learning-linux-python-3-scikit-learn/?utm_source=r-python
/r/Python
https://redd.it/5l9gtg
Django points to the wrong version of Postgres
I downgraded Postgres.app from 9.6 to 9.5 by removing the Postgres.app desktop app. I updated the database by doing
(I downloaded Postgres by downloading Postgres.app Desktop app and I installed Django by doing pip install Django)
sudo /usr/libexec/locate.updatedb
And it looks like it is initiating database from the right directory.
/Applications/Postgres.app/Contents/Versions/9.5/bin/initdb
/Applications/Postgres.app/Contents/Versions/9.5/share/doc/postgresql/html/app-initdb.html
/Applications/Postgres.app/Contents/Versions/9.5/share/man/man1/initdb.1
However, when I am trying to do a migration in my Django app, it looks like the path is still point to the 9.6 version of Postgress
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/models.py", line 4, in <module>
from tenant_schemas.postgresql_backend.base import _check_schema_name
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/postgresql_backend/base.py", line 14, in <module>
import psycopg2
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib
Referenced from: /Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: image not found
What I have tried:
1. uninstalled and reinstalled psycopg2
2. updated my database
Does anyone have recommendation as of how to reset path reference?
/r/django
https://redd.it/5kypf9
I downgraded Postgres.app from 9.6 to 9.5 by removing the Postgres.app desktop app. I updated the database by doing
(I downloaded Postgres by downloading Postgres.app Desktop app and I installed Django by doing pip install Django)
sudo /usr/libexec/locate.updatedb
And it looks like it is initiating database from the right directory.
/Applications/Postgres.app/Contents/Versions/9.5/bin/initdb
/Applications/Postgres.app/Contents/Versions/9.5/share/doc/postgresql/html/app-initdb.html
/Applications/Postgres.app/Contents/Versions/9.5/share/man/man1/initdb.1
However, when I am trying to do a migration in my Django app, it looks like the path is still point to the 9.6 version of Postgress
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/models.py", line 4, in <module>
from tenant_schemas.postgresql_backend.base import _check_schema_name
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/tenant_schemas/postgresql_backend/base.py", line 14, in <module>
import psycopg2
File "/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib
Referenced from: /Users/me/Desktop/myapp/venv/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: image not found
What I have tried:
1. uninstalled and reinstalled psycopg2
2. updated my database
Does anyone have recommendation as of how to reset path reference?
/r/django
https://redd.it/5kypf9
Would somebody be willing to do a rapid Q+A fire with me/code review with setting up my Flask backend for an iOS app?
Wondering if anyone is willing. I don't feel like just copying and pasting code, it would be much easier if I could talk in a chatroom type setting with somebody looking at my github repo. This is my first time setting up a backend and I think I'm on the right track with getting everything setup with Alamofire and proper routing, but I'm stuck on some nitty gritty stuff.
/r/flask
https://redd.it/5lbbou
Wondering if anyone is willing. I don't feel like just copying and pasting code, it would be much easier if I could talk in a chatroom type setting with somebody looking at my github repo. This is my first time setting up a backend and I think I'm on the right track with getting everything setup with Alamofire and proper routing, but I'm stuck on some nitty gritty stuff.
/r/flask
https://redd.it/5lbbou
reddit
Would somebody be willing to do a rapid Q+A fire with... • /r/flask
Wondering if anyone is willing. I don't feel like just copying and pasting code, it would be much easier if I could talk in a chatroom type...
DjangoHero : The fastest way to set up a Django project on the cloud
https://github.com/gutfeeling/djangohero
/r/django
https://redd.it/5lbrob
https://github.com/gutfeeling/djangohero
/r/django
https://redd.it/5lbrob
GitHub
gutfeeling/djangohero
djangohero - DjangoHero automates the process of starting a new Django project on Heroku
Field metadata for name of choices
I've got a problem, I'm hoping someone here could help me.
If I have a field that has choices defined for it and I do
blah = field.choices it returns the tuple such as [('requested', 'Requested'), ('company-approval', 'Ready for Company Approval'), ('client-approval', 'Ready for Client Approval')]
what I'm looking for is what would I access for it to just return to me the variable that tuple is stored in in the models file.
Ex) if you have
status = models.CharField(choices=STATUS_CHOICES)
i'd want it to return to me 'STATUS_CHOICES' instead of the contents of that tuple
Thanks in advance!
/r/django
https://redd.it/5kyw3w
I've got a problem, I'm hoping someone here could help me.
If I have a field that has choices defined for it and I do
blah = field.choices it returns the tuple such as [('requested', 'Requested'), ('company-approval', 'Ready for Company Approval'), ('client-approval', 'Ready for Client Approval')]
what I'm looking for is what would I access for it to just return to me the variable that tuple is stored in in the models file.
Ex) if you have
status = models.CharField(choices=STATUS_CHOICES)
i'd want it to return to me 'STATUS_CHOICES' instead of the contents of that tuple
Thanks in advance!
/r/django
https://redd.it/5kyw3w
reddit
Field metadata for name of choices • /r/django
I've got a problem, I'm hoping someone here could help me. If I have a field that has choices defined for it and I do blah = field.choices it...
Does modern web development focus on the backend only providing an API?
Hello,
First, apologies for the beginner question.
I'm building an application that provides user registration, payment, and just general website stuff in Django.
* If I am doing this completely fresh, should I just focus on providing a REST API for all of these things and then using React.js or Vue.js to render the forms?
* Should I avoid using a JS library completely if nothing is a SPA?
* What is current practice for new projects where the focus is just having a modern, best practices, website?
Thanks for any help and again apologize for the beginner question.
/r/django
https://redd.it/5lc6qd
Hello,
First, apologies for the beginner question.
I'm building an application that provides user registration, payment, and just general website stuff in Django.
* If I am doing this completely fresh, should I just focus on providing a REST API for all of these things and then using React.js or Vue.js to render the forms?
* Should I avoid using a JS library completely if nothing is a SPA?
* What is current practice for new projects where the focus is just having a modern, best practices, website?
Thanks for any help and again apologize for the beginner question.
/r/django
https://redd.it/5lc6qd
reddit
Does modern web development focus on the backend only... • /r/django
Hello, First, apologies for the beginner question. I'm building an application that provides user registration, payment, and just general...
My first "professional" program
Hello, long time lurker of this sub. I've been wanting to learn python for a long time because I've been making computer graphics with blender 3D for over 10 years.
So a little over a year ago I decided to start teaching myself. I started with codeacadamy's python course and then worked on several small personal projects. Such as automating some stuff at work. I then did [Udacitys Intro To Programming Nanodegree.](https://www.udacity.com/course/intro-to-programming-nanodegree--nd000) I overall feel pretty confident with python now, but it's hard to gauge how good you are at something if you don't reference it with other people. So here I am to share!
So I currently work as what is probably best described as a "security guard supervisor" all though it is a lot more than that. I work at a charity with a low income housing complex in which all guests or staff are required to sign in and out of the building. This is necessary because of certain laws requiring it with charities(it's complicated). And also so roll calls can be done with the staff if there is a fire alarm.
Before they simply had a binder with a pen and paper to sign in and out. I asked around and found out that we could print barcodes easily on to our ID cards. So I figured the entire process is pretty low hanging fruit for automation. So I presented my idea to my manager and then later some directors and they approved, since it was practically a free solution, aside from my time on the clock.
I did a back of the envelope calculation and determined this program would save about 400+ man hours a year.
**TL;DR:** So long story short even though I'm a technically a security guard they let me write python and implement this new system. Which I've had a bunch of staff thank me for because the old way was a a lot more of a pain in the ass.
[Here is the program I wrote.](https://github.com/JosiahSwaim/Punch-IN-OUT)
I want to pursue programming as a career now so any advice is appreciated too.
/r/Python
https://redd.it/5lbwu4
Hello, long time lurker of this sub. I've been wanting to learn python for a long time because I've been making computer graphics with blender 3D for over 10 years.
So a little over a year ago I decided to start teaching myself. I started with codeacadamy's python course and then worked on several small personal projects. Such as automating some stuff at work. I then did [Udacitys Intro To Programming Nanodegree.](https://www.udacity.com/course/intro-to-programming-nanodegree--nd000) I overall feel pretty confident with python now, but it's hard to gauge how good you are at something if you don't reference it with other people. So here I am to share!
So I currently work as what is probably best described as a "security guard supervisor" all though it is a lot more than that. I work at a charity with a low income housing complex in which all guests or staff are required to sign in and out of the building. This is necessary because of certain laws requiring it with charities(it's complicated). And also so roll calls can be done with the staff if there is a fire alarm.
Before they simply had a binder with a pen and paper to sign in and out. I asked around and found out that we could print barcodes easily on to our ID cards. So I figured the entire process is pretty low hanging fruit for automation. So I presented my idea to my manager and then later some directors and they approved, since it was practically a free solution, aside from my time on the clock.
I did a back of the envelope calculation and determined this program would save about 400+ man hours a year.
**TL;DR:** So long story short even though I'm a technically a security guard they let me write python and implement this new system. Which I've had a bunch of staff thank me for because the old way was a a lot more of a pain in the ass.
[Here is the program I wrote.](https://github.com/JosiahSwaim/Punch-IN-OUT)
I want to pursue programming as a career now so any advice is appreciated too.
/r/Python
https://redd.it/5lbwu4
Udacity
Introduction to Programming Online Training Course | Udacity
Sign up for Udacity's Introduction to Programming online course and take the first step toward a career in Web and App Development, Machine Learning, and more!
[D] Predicting Medical AI in 2017
https://lukeoakdenrayner.wordpress.com/2016/12/31/predicting-medical-ai-in-2017/
/r/MachineLearning
https://redd.it/5l9n3s
https://lukeoakdenrayner.wordpress.com/2016/12/31/predicting-medical-ai-in-2017/
/r/MachineLearning
https://redd.it/5l9n3s
Lauren Oakden-Rayner
Predicting Medical AI in 2017
Welcome to 2017! What a blast 2016 was. It seemed like every day there was a new, massive breakthrough in deep learning research. It was also the year that the wider world really started to take no…
Why is Django much less popular?
Development trends shift and change. Once there was no Ruby, then there were RoR developers. I know/suspect Django had more time in the sun some years ago but I can't for the life of me understand how it did not eclipse other frameworks/CMSs.
Someone posted a comment from Zuckerberg where he mentions Python is a good language to learn in the long term. PHP clearly has many problems and everyone acknowledges this so how does Django sit quietly in the background? Python is an immensely better language and I'm almost certain everyone knows this. I would've thought with all the complaints about PHP, more people would've just put it aside.
/r/Python
https://redd.it/5lcfka
Development trends shift and change. Once there was no Ruby, then there were RoR developers. I know/suspect Django had more time in the sun some years ago but I can't for the life of me understand how it did not eclipse other frameworks/CMSs.
Someone posted a comment from Zuckerberg where he mentions Python is a good language to learn in the long term. PHP clearly has many problems and everyone acknowledges this so how does Django sit quietly in the background? Python is an immensely better language and I'm almost certain everyone knows this. I would've thought with all the complaints about PHP, more people would've just put it aside.
/r/Python
https://redd.it/5lcfka
reddit
Why is Django much less popular? • /r/Python
Development trends shift and change. Once there was no Ruby, then there were RoR developers. I know/suspect Django had more time in the sun some...
How to deploy a multi-tenant django app to AWS?
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed the general Elastic Beanstalk tutorial to deploy a simple app. (https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/) However, I am looking for a solution that allows me to more flexibly create different "sites". Currently, I have learned to create different sites via this tutorial (http://mycodesmells.com/post/django-tutorial-multi-tenant-setup). And I don't have a good idea as of 1. how to deploy this app 2. how I could create different sites after deploying this app.
/r/django
https://redd.it/5lcmtf
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed the general Elastic Beanstalk tutorial to deploy a simple app. (https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/) However, I am looking for a solution that allows me to more flexibly create different "sites". Currently, I have learned to create different sites via this tutorial (http://mycodesmells.com/post/django-tutorial-multi-tenant-setup). And I don't have a good idea as of 1. how to deploy this app 2. how I could create different sites after deploying this app.
/r/django
https://redd.it/5lcmtf
Realpython
Deploying a Django App to AWS Elastic Beanstalk – Real Python
Let's look at how to deploy a Django App to AWS Elastic Beanstalk.
Does anyone use Tkinter anymore?
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in Python, I'm going to need Python anyways. However, I'm not familiar with any GUI library in Python, though I've heard a bit about Tkinter.
However, the last I heard about that, it seemed to have gathered rust and not being used as much as wxwidgets and others (even Guide Van Rossum seemed to be favoring wxwidgets).
For basic GUI stuff (lists, dropdowns, buttons and maybe a few charts), what library do you suggest?
/r/Python
https://redd.it/5laauy
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in Python, I'm going to need Python anyways. However, I'm not familiar with any GUI library in Python, though I've heard a bit about Tkinter.
However, the last I heard about that, it seemed to have gathered rust and not being used as much as wxwidgets and others (even Guide Van Rossum seemed to be favoring wxwidgets).
For basic GUI stuff (lists, dropdowns, buttons and maybe a few charts), what library do you suggest?
/r/Python
https://redd.it/5laauy
reddit
Does anyone use Tkinter anymore? • /r/Python
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in...
Help with Flask-login and sqlite3
Hi all,
I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for this. I think I am close to getting it up and running but it seems that when I run the login page, it runs the load_user function twice and the second time load_user is called it returns an empty list which predictably causes some problems (this shows up in the "print result" line in the load_user). ~~I have no idea why the load_user is being called twice~~. It is being called once on the GET and again on the POST, I still don't know why this is happening. I tried debugging it but I've had no luck. I've been trying so many different things that if it is easier just to point me towards a tutorial on how this works, I would appreciate that as well (one that covers databases). I've read the official docs and they were not clear enough for me unfortunately. Here is the code I am using
from flask import Flask, Response, request, redirect, abort, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
from database import database
app = Flask(__name__)
# config
app.config.update(
DEBUG=True,
SECRET_KEY='secret_xxx'
)
# _________________________________________________________________________________________________________________
# flask-login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "/login"
class User(UserMixin):
def __init__(self, id, name, password):
self.id = unicode(id)
self.name = name
self.password = password
self.authenticated = False
def is_active(self):
# code to check if user is active
return self.is_active()
def is_anonymous(self):
return False
def is_authenticated(self):
return self.authenticated
def is_active(self):
return True
def get_id(self):
return self.id
# __________________________________________________________________________________________________________________
@app.route('/', methods=['GET', 'POST'])
def index():
# Here we use a class of some kind to represent and validate our
return Response ("hello world everyone!")
# some protected url
@app.route('/protected')
@login_required
def protected():
return Response("""
<p>Hello protected!</p>
""")
def sign_in_user(username, password):
user = load_user(username)
if user and user.password == password:
user.authenticated = True
login_user(user)
return user
@app.route("/login", methods=["GET", "POST"], endpoint='login')
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
user = sign_in_user(username, password)
if user.is_authenticated:
return redirect('protected')
else:
return redirect('login')
else:
return Response('''
<form action="" method="post">
<p><input type=text name=username>
<p><input type=password name=password>
<p><input type=submit value=Login>
</form>
''')
@login_manager.user_loader
def load_user(username):
print "load user called"
mydatabase = database()
result = mydatabase.queryUser(username)
print result
if result == None:
return None
else:
user = User(result[0], result[1], result[2])
return user
if __name__ == "__main__":
app.run()
/r/flask
https://redd.it/5ldblw
Hi all,
I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for this. I think I am close to getting it up and running but it seems that when I run the login page, it runs the load_user function twice and the second time load_user is called it returns an empty list which predictably causes some problems (this shows up in the "print result" line in the load_user). ~~I have no idea why the load_user is being called twice~~. It is being called once on the GET and again on the POST, I still don't know why this is happening. I tried debugging it but I've had no luck. I've been trying so many different things that if it is easier just to point me towards a tutorial on how this works, I would appreciate that as well (one that covers databases). I've read the official docs and they were not clear enough for me unfortunately. Here is the code I am using
from flask import Flask, Response, request, redirect, abort, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
from database import database
app = Flask(__name__)
# config
app.config.update(
DEBUG=True,
SECRET_KEY='secret_xxx'
)
# _________________________________________________________________________________________________________________
# flask-login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "/login"
class User(UserMixin):
def __init__(self, id, name, password):
self.id = unicode(id)
self.name = name
self.password = password
self.authenticated = False
def is_active(self):
# code to check if user is active
return self.is_active()
def is_anonymous(self):
return False
def is_authenticated(self):
return self.authenticated
def is_active(self):
return True
def get_id(self):
return self.id
# __________________________________________________________________________________________________________________
@app.route('/', methods=['GET', 'POST'])
def index():
# Here we use a class of some kind to represent and validate our
return Response ("hello world everyone!")
# some protected url
@app.route('/protected')
@login_required
def protected():
return Response("""
<p>Hello protected!</p>
""")
def sign_in_user(username, password):
user = load_user(username)
if user and user.password == password:
user.authenticated = True
login_user(user)
return user
@app.route("/login", methods=["GET", "POST"], endpoint='login')
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
user = sign_in_user(username, password)
if user.is_authenticated:
return redirect('protected')
else:
return redirect('login')
else:
return Response('''
<form action="" method="post">
<p><input type=text name=username>
<p><input type=password name=password>
<p><input type=submit value=Login>
</form>
''')
@login_manager.user_loader
def load_user(username):
print "load user called"
mydatabase = database()
result = mydatabase.queryUser(username)
print result
if result == None:
return None
else:
user = User(result[0], result[1], result[2])
return user
if __name__ == "__main__":
app.run()
/r/flask
https://redd.it/5ldblw
reddit
Help with Flask-login and sqlite3 • /r/flask
Hi all, I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for...
Calling Python from React in an Electron App
https://gitlab.com/avilay/electron-react-python-app
/r/Python
https://redd.it/5lefaz
https://gitlab.com/avilay/electron-react-python-app
/r/Python
https://redd.it/5lefaz
GitLab
avilay / electron-react-python-app
Global redirect if a certain criteria isn't set
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for the life of me figure out an elegant way to get this accomplished
/r/django
https://redd.it/5ler7x
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for the life of me figure out an elegant way to get this accomplished
/r/django
https://redd.it/5ler7x
reddit
Global redirect if a certain criteria isn't set • /r/django
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for...
What's really up with apps?
Hi /r/django!
So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an explanation that I can understand xD
When do I choose to split a single project into multiple apps? As an example, right now I'm planning an accounting project that looks like "mint.com". It should contain a part for adding, viewing, categorizeing etc transactions, and one part to create and manage budgets. should these two parts be two apps? Why / Why not? This project also uses the same design layout, both for the transaction logging and the budgets. How is this handled if multiple apps are using the same static files and blocks?
Thanks for help in advance! :-D
/r/django
https://redd.it/5lf31s
Hi /r/django!
So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an explanation that I can understand xD
When do I choose to split a single project into multiple apps? As an example, right now I'm planning an accounting project that looks like "mint.com". It should contain a part for adding, viewing, categorizeing etc transactions, and one part to create and manage budgets. should these two parts be two apps? Why / Why not? This project also uses the same design layout, both for the transaction logging and the budgets. How is this handled if multiple apps are using the same static files and blocks?
Thanks for help in advance! :-D
/r/django
https://redd.it/5lf31s
reddit
What's really up with apps? • /r/django
Hi /r/django! So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an...
Can python pickle files act as a small database system backend?
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating through a python list or dict and writing each record to sqlite cursor, why not just pickle the entire object and take it from then on? How feasible is this thing, have you ever tried it?
/r/Python
https://redd.it/5lf5ur
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating through a python list or dict and writing each record to sqlite cursor, why not just pickle the entire object and take it from then on? How feasible is this thing, have you ever tried it?
/r/Python
https://redd.it/5lf5ur
reddit
Can python pickle files act as a small database system... • /r/Python
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating...