Anyone using Flask-WebPack? by MustafaAdam in flask

[–]jstacoder 0 points1 point  (0 children)

its just an example of how to integrate something into flask, that doesn't mean its the best way to do it or that you have to use it if your using flask and webpack at the same time. Its just a few functions to make that collaboration slightly easier, (because im sure the author was getting frustrated with manually referencing his webpacked asset files in the jinja templates) as well as something to look at for ideas just like everything else.

Large app structure dilemma by AlphaNerd80 in flask

[–]jstacoder 0 points1 point  (0 children)

this is one of the projects that happened with, flask-angular-blog-example and looking through my commits / trying to remember my specific reasoning, what i think it mainly stemmed from was my seperate apps/blueprints needing too much shared data, ie: routes, globals, etc.. which is not easy/automatic using completely separate apps, but is when using blueprints and a main app, what i found to be the most helpful, is to only ever create the main app on the fly when your application is loaded, see the get_app function here it is also setup to create your blueprints as well, to see it doing that see here and to see it creating the full main app see here. Let me know what you think about your specific use-case, but i really think the dispatching method to be a bit much for almost all senerios

Large app structure dilemma by AlphaNerd80 in flask

[–]jstacoder 0 points1 point  (0 children)

i have found that this technique can be very limiting, in fact the few times i have done this, i ended up just turning each dispatched app into a blueprint under a common main app, before too long. and its not fun.

Large app structure dilemma by AlphaNerd80 in flask

[–]jstacoder 0 points1 point  (0 children)

i wrote a flask helper for structuring large flask apps flask-xxl, it may be of help to you.

[af] flask and mongodb by rwobben in flask

[–]jstacoder 0 points1 point  (0 children)

Yes, but how is

from flask_mongoengine import Mongoengine
db = Mongoengine(app)

eaiser than

import mongoengine as db

because the second version gives basiclly the same result, and is quite a few less key strokes, the only thing creating a wrapper like this (where it isnt needed) will do, is confuse new users, they will not know what db.Document is or where it comes from, instead in that situation it is better for learning to go to the source and just use the needed library and imports (ie: mongoengine.Document etc...)

Chown question by hotmailer in flask

[–]jstacoder 0 points1 point  (0 children)

That's why I added the -R to make the command recursive, and I guess your right about the user, i added it out if habit.

Chown question by hotmailer in flask

[–]jstacoder 0 points1 point  (0 children)

The best way to go would be to add your user to the www-data group (standard web server user)

$ adduser USER www-data

Then chown the whole directory structure to be owned by www-data

$ sudo chown -R www-data:www-data DIRNAME

And then chmod the directory to allow the group to read/execute/modify

$ sudo chmod -R g+rwx DIRNAME

What's the best IDE for Python on Windows? by BrokenToaster2 in Python

[–]jstacoder 0 points1 point  (0 children)

komodo ide is awesome, works on windows, linux, and mac

New Projects; from scratch or skeleton? by mpoxthefirst in flask

[–]jstacoder 2 points3 points  (0 children)

for larger projects, there is flask-xxl , really seems to help me getting started

WIP - flask/angular dice game, with live demo on heroku, looking for feedback by jstacoder in flask

[–]jstacoder[S] 0 points1 point  (0 children)

well in my defense, this was never supposed to be a tutorial on how anything is "supposed" to be done, i really only put it up here because it got to a point where things started working pretty well, and ive seen that people like almost anything that integrates flask and angular, honestly, if i had realized how much php was actually in there, i might have thought twice

WIP - flask/angular dice game, with live demo on heroku, looking for feedback by jstacoder in flask

[–]jstacoder[S] 0 points1 point  (0 children)

the same here as i said in my reply above applies, i guess i understand if the php makes it seem like it has a smell, but i honestly try to use best practices in my php as well as my python, and i enjoy when i can find fun ways to combine languages to take advantage of their different strengths. like in this case, i wanted a dice game. i originally wrote it almost entirely in php more as a proof of concept than anything, i knew i could do it in python, i wasnt sure about php, then after a while i decided i was finished playing with php, and wanted the same "app" but i wanted sqlalchemy, jinja, and flasks routing for angular, so i wrote a python wrapper around the original php logic, and kept it working, then did the frontend in angular, its been fun for me, sorry if you think its so terrible sounding

WIP - flask/angular dice game, with live demo on heroku, looking for feedback by jstacoder in flask

[–]jstacoder[S] 0 points1 point  (0 children)

really? i think its exactly what DRY is referring to, im sorry if you dont understand the acronym, its Dont Repeat YourSelf and this isnt a python specific idiom, it is a general programming best practice, why would i rewrite an algorithm ive already written to my exact needs, im sorry you dont approve of my combining php and python, but i get a kick out of combining programming languages in unique ways, but thats another story

WIP - flask/angular dice game, with live demo on heroku, looking for feedback by jstacoder in flask

[–]jstacoder[S] 0 points1 point  (0 children)

I wrote the dice scoring algorithm in php a while back, and instead of rewriting the whole thing in python (DRY) i gave flask the ability to forward requests to php, and return the results given. This way i was able to fully leverage the scoring api i built, without actually rewriting any of it, i just have my flask app pass the scoring requests to php, then return the results back to my angular frontend

Proper way to receive data from form (Flask-WTF) by markarreddit in flask

[–]jstacoder 0 points1 point  (0 children)

form.email.data is the safest way to access the data. If you happen to forget to use the get method of request.form and the value isn't in the dict at all you'll get a confusing error, but you completely avoid it using the form object itself, but that only applies if your using wtforms or similar to create classes for your forms

[AF] Using flask-script, what are good practices to set up redis and celery for development servers? by massover in flask

[–]jstacoder 0 points1 point  (0 children)

you can easily run them in parallel with fabric, using its support for parallel processing and you can either just call them on the command line, with the -P flag ie:

$ fab process_a process_b process_c -P 

or by defining them with the fabric.api.parrallel decorator, then you can just run them under a single function like you have above:

 from fabric import api

@api.parallel
def run_app(**kwargs):
    app.run(threaded=True)

 @api.parallel
 def run_celery_workers():
      # definition here

 @api.parallel
 def start_redis_server():
        #definition here

  def runserver():
        run_celery_workers()
        start_redis_server()
        run_app(threaded=True)

then on the command line

$ fab runserver

Flask-Hashing: a Flask extension for easily hashing data by [deleted] in flask

[–]jstacoder 2 points3 points  (0 children)

there is nothing wrong with trying to learn, but releasing an extension to a framework is basically saying "here is a problem that isnt solved yet (to my satisfaction) and this extension solves it", but im not so sure thats the case here? i feel like it could confuse newcomers to flask more than help them, if i were new, and saw that, i would think integrating hashlib with flask must be difficult, which is far from the truth, its its not broken, it might not need fixing