Looking for advice on how to structure my app
Hello,
I am working on an application that has a web interface that users can register on but mainly works with sending text messages.
Since I am kind of new to Flask, I am unsure about how to structure this application. I have not yet finished the functionality of the app but this is what my structure looks like right now:
​
project folder
* main
* assets
* core
* \_\_init\_\_.py
* views.py
* messages
* \_\_init\_\_.py
* views.py
* logic
* logic.py
* static
* templates
* users
* \_\_init\_\_.py
* views.py
* \_\_init\_\_.py
* models.py
* [app.py](https://app.py)
​
Within the core folder, I have the views that actually render templates for the website visitor to see. The messages/views.py includes the routes that handle the text messaging.
Now what I am mainly concerned about is my logic folder. I want to set this app up so that every day at a given time,
/r/flask
https://redd.it/at8xb6
Hello,
I am working on an application that has a web interface that users can register on but mainly works with sending text messages.
Since I am kind of new to Flask, I am unsure about how to structure this application. I have not yet finished the functionality of the app but this is what my structure looks like right now:
​
project folder
* main
* assets
* core
* \_\_init\_\_.py
* views.py
* messages
* \_\_init\_\_.py
* views.py
* logic
* logic.py
* static
* templates
* users
* \_\_init\_\_.py
* views.py
* \_\_init\_\_.py
* models.py
* [app.py](https://app.py)
​
Within the core folder, I have the views that actually render templates for the website visitor to see. The messages/views.py includes the routes that handle the text messaging.
Now what I am mainly concerned about is my logic folder. I want to set this app up so that every day at a given time,
/r/flask
https://redd.it/at8xb6
Using other front end frame works with flask
Are there any other front end frame works that I can use with flask. Was using jinja2 which I’ve found to be a little slow. Currently teaching myself how to use vuejs. Returning everything in json now. Could return everything and use jquery to populate html.
Thanks in advance
/r/flask
https://redd.it/ata3vr
Are there any other front end frame works that I can use with flask. Was using jinja2 which I’ve found to be a little slow. Currently teaching myself how to use vuejs. Returning everything in json now. Could return everything and use jquery to populate html.
Thanks in advance
/r/flask
https://redd.it/ata3vr
reddit
r/flask - Using other front end frame works with flask
0 votes and 1 comment so far on Reddit
Design advice needed: Editing models in views
Hello,
I'm somewhat new to Django/front end web development so I'm wondering what the best way to accomplish this would be. I have a "Rule" model which is made up of a few other models. On the view page, I'd like to list all the Rules with their associated attributes. In each Rule, I'd like the user to be able to edit it and adjust the attributes associated with the Rule. Once they click save, I'd like to update the relevant models in the database and reflect that on the page, but I DO NOT want the page to refresh. I know I can do this using a JS library but it seems, from my research, that'd I'd have to create a rather janky and potentially insecure POST request. I could use ModelForms, but I'm unclear how I basically keep the entire page from refreshing rather than just the individual Rule being edited. Any advice on how to accomplish this is GREATLY appreciated. Thanks!
/r/django
https://redd.it/atbh25
Hello,
I'm somewhat new to Django/front end web development so I'm wondering what the best way to accomplish this would be. I have a "Rule" model which is made up of a few other models. On the view page, I'd like to list all the Rules with their associated attributes. In each Rule, I'd like the user to be able to edit it and adjust the attributes associated with the Rule. Once they click save, I'd like to update the relevant models in the database and reflect that on the page, but I DO NOT want the page to refresh. I know I can do this using a JS library but it seems, from my research, that'd I'd have to create a rather janky and potentially insecure POST request. I could use ModelForms, but I'm unclear how I basically keep the entire page from refreshing rather than just the individual Rule being edited. Any advice on how to accomplish this is GREATLY appreciated. Thanks!
/r/django
https://redd.it/atbh25
reddit
r/django - Design advice needed: Editing models in views
0 votes and 2 comments so far on Reddit
What happened to Oriole Online Tutorials on Safari Books? They have stopped doing those
I was swiping through O'reilly's library with tuts - found those some time ago but there is nothing new on Jupyter. Thanks!
/r/JupyterNotebooks
https://redd.it/at8win
I was swiping through O'reilly's library with tuts - found those some time ago but there is nothing new on Jupyter. Thanks!
/r/JupyterNotebooks
https://redd.it/at8win
reddit
r/JupyterNotebooks - What happened to Oriole Online Tutorials on Safari Books? They have stopped doing those
1 vote and 0 comments so far on Reddit
This media is not supported in your browser
VIEW IN TELEGRAM
y’all are so are so advanced with you project but this is my first project in python hope u like it😂
/r/Python
https://redd.it/ataswq
/r/Python
https://redd.it/ataswq
Question about handling authentications with tokens using Django Rest framework
Hello everyone! I am trying to build a mobile application with Django in the backend. For this I am using Django rest framework. Looking at the docs, I am confused about the usage of OAuth or JWT Authentication in my application. I have been using djangorestframework-jwt but this doesn't support obtaining access token after they expire using the refresh token mechanism (Note: It only supports the mechanism to refresh token before it is expired which is a different thing). So I am thinking of going with django-rest-framework-simplejwt. However, this doesn't store the refresh tokens in the database. Are there any drawbacks to it? Can I use it in my application without having to worry about the security provided that both the access-token and refresh-tokens stored in the local storage of the device are encrypted? Or is there anything else, I need to consider before taking this route? And what functionality do the Oauth toolkits provide? As far as I know OAuth is a protocol for authentication which may or may not use JWTs as token formats. Do I need to use them for better functionality whatever they maybe? To keep it simple, I just need to do what the mobile
/r/djangolearning
https://redd.it/asas6t
Hello everyone! I am trying to build a mobile application with Django in the backend. For this I am using Django rest framework. Looking at the docs, I am confused about the usage of OAuth or JWT Authentication in my application. I have been using djangorestframework-jwt but this doesn't support obtaining access token after they expire using the refresh token mechanism (Note: It only supports the mechanism to refresh token before it is expired which is a different thing). So I am thinking of going with django-rest-framework-simplejwt. However, this doesn't store the refresh tokens in the database. Are there any drawbacks to it? Can I use it in my application without having to worry about the security provided that both the access-token and refresh-tokens stored in the local storage of the device are encrypted? Or is there anything else, I need to consider before taking this route? And what functionality do the Oauth toolkits provide? As far as I know OAuth is a protocol for authentication which may or may not use JWTs as token formats. Do I need to use them for better functionality whatever they maybe? To keep it simple, I just need to do what the mobile
/r/djangolearning
https://redd.it/asas6t
reddit
r/djangolearning - Question about handling authentications with tokens using Django Rest framework
6 votes and 1 comment so far on Reddit
Flask-login limit pages to admin accounts
I've implemented Flask-login extension on my site which I am very happy with. I don't want to use Flask-user yet as I want to understand everything before I give over control and become dependant on Flask-user for everything.
I've been using my google-fu for about two days and I can't find a simple way to limit pages for admins in a pythonic/flask type way. My current hack involves something like this:
@admin.route("/admin")
@login_required
def admin_home():
account_type = current_user.account_type
if account_type == "admin":
return render_template("admin/admin.html")
else:
return redirect(url_for("member.member_page"))
Which works and I will turn it into a function if its the best way to do it. BUT I can't believe there isn't a snippit
I've built my own decorator before, would you build a new decorator to between the function and the @login\_required? Or is there some easy way that I haven't found? Nothing
/r/flask
https://redd.it/ath57t
I've implemented Flask-login extension on my site which I am very happy with. I don't want to use Flask-user yet as I want to understand everything before I give over control and become dependant on Flask-user for everything.
I've been using my google-fu for about two days and I can't find a simple way to limit pages for admins in a pythonic/flask type way. My current hack involves something like this:
@admin.route("/admin")
@login_required
def admin_home():
account_type = current_user.account_type
if account_type == "admin":
return render_template("admin/admin.html")
else:
return redirect(url_for("member.member_page"))
Which works and I will turn it into a function if its the best way to do it. BUT I can't believe there isn't a snippit
I've built my own decorator before, would you build a new decorator to between the function and the @login\_required? Or is there some easy way that I haven't found? Nothing
/r/flask
https://redd.it/ath57t
reddit
r/flask - Flask-login limit pages to admin accounts
3 votes and 3 comments so far on Reddit
sessions persisting across requests
Hi all, I'm running flask with gunicorn and having issues with the session persisting across requests.
the session persists when going from /set to /check. But when a session value is set in the authenticate route
it is then lost, no idea why this is happening and a bit lost now.
# //-- api route app.py
from flask import Flask, session
from flask_session import Session
import routes.authenticate
import redis
Authenticate = routes.authenticate.Authenticate()
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'redis'
app.SESSION_REDIS = redis.Redis("redis")
app.secret_key = "123"
sess = Session()
sess.init_app(app)
@app.route("/set", methods=["GET"])
def set():
session["test] = "foo"
print(session)
/r/flask
https://redd.it/at1cwy
Hi all, I'm running flask with gunicorn and having issues with the session persisting across requests.
the session persists when going from /set to /check. But when a session value is set in the authenticate route
it is then lost, no idea why this is happening and a bit lost now.
# //-- api route app.py
from flask import Flask, session
from flask_session import Session
import routes.authenticate
import redis
Authenticate = routes.authenticate.Authenticate()
app = Flask(__name__)
app.config['SESSION_TYPE'] = 'redis'
app.SESSION_REDIS = redis.Redis("redis")
app.secret_key = "123"
sess = Session()
sess.init_app(app)
@app.route("/set", methods=["GET"])
def set():
session["test] = "foo"
print(session)
/r/flask
https://redd.it/at1cwy
reddit
r/flask - sessions persisting across requests
1 vote and 4 comments so far on Reddit
Serialchemy: a library to serialize/deserialize SQLAlchemy models
https://github.com/esss/serialchemy
_Serialchemy was developed as a module of a lib to create Restful APIs using Flask and SQLAlchemy. We first tried marshmallow-sqlalchemy, probably the most well-known lib for SQLAlchemy model serialization, but we faced issues related to nested models. We also think that is possible to build a simpler and more maintainable solution by having SQLAlchemy in mind from the ground up, as opposed to marshmallow-sqlalchemy that had to be designed and built on top of marshmallow._
Suggestions and reviews are extremely welcome.
/r/flask
https://redd.it/atom47
https://github.com/esss/serialchemy
_Serialchemy was developed as a module of a lib to create Restful APIs using Flask and SQLAlchemy. We first tried marshmallow-sqlalchemy, probably the most well-known lib for SQLAlchemy model serialization, but we faced issues related to nested models. We also think that is possible to build a simpler and more maintainable solution by having SQLAlchemy in mind from the ground up, as opposed to marshmallow-sqlalchemy that had to be designed and built on top of marshmallow._
Suggestions and reviews are extremely welcome.
/r/flask
https://redd.it/atom47
GitHub
ESSS/serialchemy
Contribute to ESSS/serialchemy development by creating an account on GitHub.
Does someone has ever heard about odata and graphql?
Hi all,
currently I am reading a little about graphql, it sounds like a nice idea to make the data transaction a little faster, only add several line codes. Then I remebered another language, odata, an open data protocol, which is heavily used by SAP. Then I did a little search in google, it looks like odata is more powerful than graphql. So, I want ask you guys here, did you ever heard about the two things? Have you ever used it? What's your opinions?
​
​
/r/flask
https://redd.it/asb59s
Hi all,
currently I am reading a little about graphql, it sounds like a nice idea to make the data transaction a little faster, only add several line codes. Then I remebered another language, odata, an open data protocol, which is heavily used by SAP. Then I did a little search in google, it looks like odata is more powerful than graphql. So, I want ask you guys here, did you ever heard about the two things? Have you ever used it? What's your opinions?
​
​
/r/flask
https://redd.it/asb59s
reddit
r/flask - Does someone has ever heard about odata and graphql?
3 votes and 2 comments so far on Reddit
[D] Blog posts on AlphaStar
Hey all,
I wrote some stuff on AlphaStar. I was planning to finish this right after the match came out, but real life got in the way, and I had a lot of things I wanted to cover.
Part 1: [https://www.alexirpan.com/2019/02/22/alphastar.html](https://www.alexirpan.com/2019/02/22/alphastar.html)
Part 2: [https://www.alexirpan.com/2019/02/22/alphastar-part2.html](https://www.alexirpan.com/2019/02/22/alphastar-part2.html)
If you like it / dislike it / think my opinion is trash, let me know.
/r/MachineLearning
https://redd.it/atmxej
Hey all,
I wrote some stuff on AlphaStar. I was planning to finish this right after the match came out, but real life got in the way, and I had a lot of things I wanted to cover.
Part 1: [https://www.alexirpan.com/2019/02/22/alphastar.html](https://www.alexirpan.com/2019/02/22/alphastar.html)
Part 2: [https://www.alexirpan.com/2019/02/22/alphastar-part2.html](https://www.alexirpan.com/2019/02/22/alphastar-part2.html)
If you like it / dislike it / think my opinion is trash, let me know.
/r/MachineLearning
https://redd.it/atmxej
Alexirpan
An Overdue Post on AlphaStar, Part 2
This is part 2 of my post about AlphaStar, which is
focused on the machine learning implications.
Click here for part 1.
focused on the machine learning implications.
Click here for part 1.
Why class based views?
[http://flask.pocoo.org/docs/1.0/views/](http://flask.pocoo.org/docs/1.0/views/)
What are the advantages of constructing views via classes rather than functions? What are some things to think about when deciding one over the other?
/r/flask
https://redd.it/atsq5z
[http://flask.pocoo.org/docs/1.0/views/](http://flask.pocoo.org/docs/1.0/views/)
What are the advantages of constructing views via classes rather than functions? What are some things to think about when deciding one over the other?
/r/flask
https://redd.it/atsq5z
reddit
r/flask - Why class based views?
5 votes and 1 comment so far on Reddit
Preventing dynamic javascript output in Notebook
Hi.
I have a rather unusual problem, so I couldn't find the answer to my question. People usually want to get dynamic output in cells, not reliably prevent it.
I want to use the notebook to generate reports for student submissions, so that they and me can easily review their solutions. However to do this, I need to prevent any mischievous behaviour. :)
The way it works is, the student prepares a python module with a specified interface and uploads it to a server. In a sandbox environment I run a notebook that imports that module, runs some tests and generates some plots. The results is saved as a html, and can be displayed on the students submission page, where it can be viewed by me or him.
Is there a way to prevent the students to inject any active javascript or other malicious content into notebook cells, that might high jack my browser session (with admin/teacher login :) ) ? Do i need to prevent this in the first place?
​
/r/IPython
https://redd.it/att17t
Hi.
I have a rather unusual problem, so I couldn't find the answer to my question. People usually want to get dynamic output in cells, not reliably prevent it.
I want to use the notebook to generate reports for student submissions, so that they and me can easily review their solutions. However to do this, I need to prevent any mischievous behaviour. :)
The way it works is, the student prepares a python module with a specified interface and uploads it to a server. In a sandbox environment I run a notebook that imports that module, runs some tests and generates some plots. The results is saved as a html, and can be displayed on the students submission page, where it can be viewed by me or him.
Is there a way to prevent the students to inject any active javascript or other malicious content into notebook cells, that might high jack my browser session (with admin/teacher login :) ) ? Do i need to prevent this in the first place?
​
/r/IPython
https://redd.it/att17t
reddit
r/IPython - Preventing dynamic javascript output in Notebook
3 votes and 0 comments so far on Reddit
Google Maps data: Plot the places you have visited
https://kanoki.org/2019/01/20/thank-you-google-for-sharing-my-data/
/r/Python
https://redd.it/atrzt4
https://kanoki.org/2019/01/20/thank-you-google-for-sharing-my-data/
/r/Python
https://redd.it/atrzt4
reddit
r/Python - Google Maps data: Plot the places you have visited
120 votes and 10 comments so far on Reddit
George Hotz | Basic Programming | ipython | counterfactual regret minimization
https://youtu.be/7m4bnmSkjow
/r/IPython
https://redd.it/atuq01
https://youtu.be/7m4bnmSkjow
/r/IPython
https://redd.it/atuq01
YouTube
George Hotz | Programming | ipython | counterfactual regret minimization
Date of stream 22 Feb 2019.
Live-stream chat added as Subtitles/CC - English (Twitch Chat).
Stream title: counterfactual regret minimization
Source files:
- https://github.com/geohot
Paper:
- http://modelai.gettysburg.edu/2013/cfr/cfr.pdf
Follow for notifications:…
Live-stream chat added as Subtitles/CC - English (Twitch Chat).
Stream title: counterfactual regret minimization
Source files:
- https://github.com/geohot
Paper:
- http://modelai.gettysburg.edu/2013/cfr/cfr.pdf
Follow for notifications:…
Using the new %pip magic successfully
To use \`%pip\`, you need permission to write into pip's install prefix, which depending on the exact runtime environment you won't have (especially with JupyterHub installations). Passing the \`--user\` option will usually ensure that, but then you might want to have your notebook packages separate from ones you use in the shell – this shows how to do that.
​
See \[Embedded Dependency Installation\]([https://nbviewer.jupyter.org/github/jhermann/jupyter-by-example/blob/master/setup/configuration.ipynb#Embedded-Dependency-Installation](https://nbviewer.jupyter.org/github/jhermann/jupyter-by-example/blob/master/setup/configuration.ipynb#Embedded-Dependency-Installation)) on nbviewer for details.
/r/IPython
https://redd.it/atx1iv
To use \`%pip\`, you need permission to write into pip's install prefix, which depending on the exact runtime environment you won't have (especially with JupyterHub installations). Passing the \`--user\` option will usually ensure that, but then you might want to have your notebook packages separate from ones you use in the shell – this shows how to do that.
​
See \[Embedded Dependency Installation\]([https://nbviewer.jupyter.org/github/jhermann/jupyter-by-example/blob/master/setup/configuration.ipynb#Embedded-Dependency-Installation](https://nbviewer.jupyter.org/github/jhermann/jupyter-by-example/blob/master/setup/configuration.ipynb#Embedded-Dependency-Installation)) on nbviewer for details.
/r/IPython
https://redd.it/atx1iv
nbviewer.jupyter.org
Notebook on nbviewer
Check out this Jupyter notebook!
[D] Undergraduate student feeling completely overwhelmed
As an undergrad student with a math major that wants to pursue ML in grad school (preferably the top ones) I am feeling completely overwhelmed. I need to keep my grades and GPA high for grad school, am doing research with professors (cannot make much progress as I don't understand much of the deep learning foundations), doing side projects, applying to internships and preparing for interviews, and trying to learn as much as possible in the field. I am also trying to improve my coding skills as I lack some of the more foundational knowledge in OOP and OS and so forth since I don't have a CS major. It honestly seems impossible to balance all of this and I find myself staying up late at night stressing out and trying to cram as possible and it doesn't seem to be getting me any closer to my goals. In fact it is affecting my health and relationships. Maybe I am expecting too much of myself an undergraduate student?
The major issue is just finding the goddamn time to learn the machine learning and deep learning content and keep up with what's going on while being a full time student. Much
/r/MachineLearning
https://redd.it/atu995
As an undergrad student with a math major that wants to pursue ML in grad school (preferably the top ones) I am feeling completely overwhelmed. I need to keep my grades and GPA high for grad school, am doing research with professors (cannot make much progress as I don't understand much of the deep learning foundations), doing side projects, applying to internships and preparing for interviews, and trying to learn as much as possible in the field. I am also trying to improve my coding skills as I lack some of the more foundational knowledge in OOP and OS and so forth since I don't have a CS major. It honestly seems impossible to balance all of this and I find myself staying up late at night stressing out and trying to cram as possible and it doesn't seem to be getting me any closer to my goals. In fact it is affecting my health and relationships. Maybe I am expecting too much of myself an undergraduate student?
The major issue is just finding the goddamn time to learn the machine learning and deep learning content and keep up with what's going on while being a full time student. Much
/r/MachineLearning
https://redd.it/atu995
reddit
r/MachineLearning - [D] Undergraduate student feeling completely overwhelmed
107 votes and 55 comments so far on Reddit
[R] Evaluating the Search Phase of Neural Architecture Search: random policy outperforms state-of-the-art NAS algorithms
https://arxiv.org/abs/1902.08142
/r/MachineLearning
https://redd.it/atwnlh
https://arxiv.org/abs/1902.08142
/r/MachineLearning
https://redd.it/atwnlh
arXiv.org
Evaluating the Search Phase of Neural Architecture Search
Neural Architecture Search (NAS) aims to facilitate the design of deep networks for new tasks. Existing techniques rely on two stages: searching over the architecture space and validating the best...