|
I'm reading about RESTful web services as they relate to Flask. In the introduction, It talks about how you might need to have multiple versions of your website because not everyone can access the new version immediately (i.e. a smartphone app won't be up to the newest version until the user downloads the new version). The smartphone app was the only example given and I'm struggling to understand what else would justify having separate versions of a website with Flask? Edit: Perhaps a better question, is there a good article/resource that explains RESTful web services well? huhu fucked around with this message at 19:23 on Mar 8, 2017 |
# ¿ Mar 8, 2017 19:20 |
|
|
# ¿ Apr 29, 2024 15:19 |
|
I tried to add code:
quote:werkzeug.routing.BuildError: Could not build url for endpoint 'auth.login'. Did you mean 'login' instead? quote:The default is login but since you don't have a view named 'login' code:
|
# ¿ Mar 9, 2017 04:23 |
|
dougdrums posted:You might have done this, but the login manager class has a field "login_view" that can be set, like Thank you so much.
|
# ¿ Mar 10, 2017 01:09 |
|
My first Flask application is almost done. Hopefully one last question. I've setup Flask-Admin and it works well by routing all traffic (even non logged in users) from /admin to the admin panel. However, /admin is not a route in my views.py file. I thought I could just do something like:code:
|
# ¿ Mar 10, 2017 20:03 |
|
This code code:
code:
|
# ¿ Mar 12, 2017 21:21 |
|
I've got a login form and a registration form on a single page with a nav that toggles a hidden class between the two. By default, when the page loads, registration is set to hidden. However, if a user fills out the registration form and there are errors on submit, the page refreshes and login is loaded. How could I get the hidden class to instead be applied to registration if a user registers but has errors?
|
# ¿ Mar 17, 2017 02:47 |
|
Would this be the best way to log errors on a script that I'm running?code:
|
# ¿ Mar 28, 2017 20:39 |
|
Awesome thanks for the quick replies!
|
# ¿ Mar 28, 2017 21:12 |
|
Curious if anyone would be interested in a Flask thread? I'm starting a new job working full time with it and would love a place to discuss it more.
|
# ¿ Mar 30, 2017 04:59 |
|
I decided to write a Flask intro for anyone that is curious. Why Flask? In my opinion, Flask feels like just another package you would want to use on a project. It is simple to use and very modular. You only add new functionality – such as support for login, if you need it. It also does a great job of letting you write almost solely Python. For the backend, the database can be created without having to write SQL statements. On the frontend, forms and other page content can be created with Python instead of JavaScript. If you would prefer not to write CSS/HTML you can find pre-made static templates that are easy to integrate. Finally, it’s nice to be able to not have to deal with PHP. How to get started Both the book and tutorial are resources by the same author and they are awesome. I would recommend reading through both. Flask Book Flask Tutorial Flask Documentation What can it be used for? I’ve used it to build simple static websites and as a way to serve content, specifically images from a security camera, from my server. Additionally, I followed a tutorial for building a blog. For my new job, I’ll be building dashboards for scientists to access and analyze their data. Basic Demo Setup The basic setup steps are to install a virtual environment, activate it, and then install Flask. code:
The directory stucture consists of the folder for the virtual environment, hello.py which is defined below, and a templates directory. Templates are written in HTML and data from databases or other sources can be added to them before they are returned to the end user as a webpage. code:
The code below starts with declaring a new instance of Flask named app. To the app we add routing which is how we figure out what information we want to send back to the user. The first route, '/' which points to index() will return "Hello World" when a user visits https://www.website.com/. The second route is a little special. If someone visits https://www.website.com/user/huhu, the string 'huhu' will be passed to the user_page() function. Additionally user_page() also has a current_time which gets the current time. These two bits of data are then added to the 'user_page.html' template with the render_template() function. code:
This template takes username and current_time from the user_page() function above, adds the data to the template, and then returns it to the user. code:
The last step is to simply run the following command and the app will start: code:
|
# ¿ Mar 30, 2017 18:04 |
|
Ghost of Reagan Past posted:What's a good library for drawing an array of pixels? They would change over time (I'm not animating figures, though), and I plan on eventually feeding into some LEDs, but for now I'd rather prototype without wiring up a bunch of LEDs. I've thought of just doing it with Flask + Javascript but I'm wondering if there's some other good solution. https://python-pillow.org/ Edit: How many LEDs are you talking about by the way? Are you planning to use Arduino, Raspberry Pi, or something else?
|
# ¿ Apr 8, 2017 01:45 |
|
Ghost of Reagan Past posted:32x32 and a Pi for the prototype. We'll see whether a Pi can do what I actually have in mind at the end of the day, but I'll get there when I get there. But on a computer I can have a much higher resolution I'm probably gonna start with that. I'm okay with this taking a lot of iteration and work. Definitely go Python. It works very well with the Pi, if you didn't already know that. If you got money to burn, a guy at my hackspace built a really nice Neopixel 10x10 grid. https://www.adafruit.com/products/1138
|
# ¿ Apr 8, 2017 03:31 |
|
I'm starting to run into more advanced packages that are requiring things like Microsoft Visual C++. I've also been reading about how some things are too slow in Python so other languages are used to deal with this. Is there an article/video that explains this all well?
|
# ¿ Apr 12, 2017 16:36 |
|
Dominoes posted:Broad topic. Many python modules use C code to improve speed. When installing them from source, (Including pip without a wheel) you'll need a compiler; Visual C++ is used in Win. Which package are you referring to? You can usually avoid this by using Conda, or a Chris Gohlke binary. You've given me enough vocab I had to look up that I more or less understand what I need to know now.
|
# ¿ Apr 12, 2017 17:33 |
|
I started developing with Sublime Text and then switched to PyCharm since I've been working mostly with Python. However, my new job has me focusing on Flask apps and PyCharm seems to be a bit lacking when it comes to dealing with HTML, CSS, and JS. I miss all the awesome plugins that come with Sublime Text as well. Am I missing something or should I be looking at something else to be developing Flask stuff?
|
# ¿ Apr 12, 2017 20:59 |
|
The Fool posted:I feel like I might be saying this too often at this point, but have you considered VSCode accepted Christ as your Lord and Savior This is amazing.
|
# ¿ Apr 12, 2017 21:33 |
|
Thermopyle posted:What?
|
# ¿ Apr 13, 2017 17:32 |
|
Cingulate posted:Different question: does Continuum make money? What are the chances "conda install all_the_software_i_need" won't work in 2018 because Travis Oliphant has to choose between making it slightly easier for me to set up numpy or feeding his kids? 2018? I don't think anything is guaranteed 3 months from now.
|
# ¿ Apr 18, 2017 13:51 |
|
I've just finished my first Flask project for my new job which is basically a page with a form that allows users to do CRUD operations on a database table. It took me about a week to create. Of course there was a bunch of stuff like having to learn MySQL, JavaScript form validation, navigate their code base, etc. along the way so it took a bit of time. I was just able to recreate what took me about a week with Flask Admin in an hour and was even able to add additionally functionality like a list view, searching, and filtering. I feel like this was deceptively simple though and when I start working on more complex projects I'd be better off writing the SQL and JS myself. Is that correct?
|
# ¿ Apr 26, 2017 18:31 |
|
In Pycharm, is there a way to run code and then and then leave some sort of a command line to continue playing around with it?Thermopyle posted:What? VisualStudio feels like the Photoshop of web development -- way too bloated. I realized that all the features I expected from PyCharm exist only in the professional version so now I've got myself a copy of that.
|
# ¿ Apr 27, 2017 21:21 |
|
flosofl posted:It's got a full featured debugger if that's what you're asking. Also has an integrated terminal and python console. I guess to rephrase my question... In Python IDLE, I can run test.py, and then play around with it after. test.py code:
code:
|
# ¿ Apr 27, 2017 21:45 |
|
I've been using PyCharm for awhile now I'm just not sure how to phrase my question in Google so I'm asking here.vikingstrike posted:Highlight code, right click, execute selection in console. I highlight the entire file and do this and it gives errors. Edit: Found it http://stackoverflow.com/questions/21516027/running-code-in-pycharms-console huhu fucked around with this message at 21:53 on Apr 27, 2017 |
# ¿ Apr 27, 2017 21:47 |
|
I'm having a Pycharm or Python issue...code:
Edit: It's a Pycharm issue. I renamed the directory and reopened it in Pycharm and it's working now. Any ideas what I might triggered by renaming the directory? huhu fucked around with this message at 16:18 on May 1, 2017 |
# ¿ May 1, 2017 16:15 |
|
NtotheTC posted:Was the file actually named "foo" and the class "bar"? If not its possible you named your file something that was already taken by standard lib or an external library. Is the file in the same directory as the file you're importing into? Try Somehow between yesterday and today, and renaming the folder back to its original name, the issue is gone. This is good to know for next time though.
|
# ¿ May 2, 2017 16:54 |
|
Anyone have any good resources for getting started using extensions (C/C++) with Python? I'm taking over a script that uses this and the most complicated C++ I've written has been for Arduino so I'm not really sure what I'm doing.
|
# ¿ May 3, 2017 16:44 |
|
HardDiskD posted:The liquor store? Is it that confusing?
|
# ¿ May 3, 2017 16:56 |
|
code:
code:
|
# ¿ May 17, 2017 21:07 |
|
I would like to debug JavaScript inside a PyCharm for Flask projects. I see that I can set breakpoints in the JS code but PyCharm always skips over them. The only tutorial I can find online involves debugging static HTML and not Jinja2 templates.
|
# ¿ May 30, 2017 16:13 |
|
Thermopyle posted:I haven't debugged JS in a jetbrains IDE in years, but I seem to recall it was easier if I used an external js file included in my templates via a script tag. I might be explaining this poorly. Here's my structure: app/templates/input.html: code:
code:
Edit: The settings I think are relevent: huhu fucked around with this message at 16:26 on May 30, 2017 |
# ¿ May 30, 2017 16:22 |
|
Thermopyle posted:This is a weird thing to say, so just to make sure you didn't accidentally type the wrong thing...you know that PyCharm is an IDE and Anaconda is a package manager? I could see Pycharm being overwhelming if you've never programmed before. Perhaps better to start off with something more familiar feeling first like Sublime Text. That being said, I moved from Sublime to Pycharm in my learning progression and never plan to go back.
|
# ¿ Jun 4, 2017 15:25 |
|
What would be the best way to take: [{u'amt': 10.0}, {u'amt': 0.1}, {u'amt': 1.0}, {u'amt': 3.0}, {u'amt': 5.0}] and turn it into [10.0, 0.1, 1.0, 3.0, 5.0] edit, think I found a good way: values = [value for singleDict in dictlist for value in dict.values()] huhu fucked around with this message at 15:50 on Jun 14, 2017 |
# ¿ Jun 14, 2017 15:43 |
|
I'm reading up on Breadth First Search and this is the implementation the video I'm watching talks about :code:
Edit: I'm thinking this would be good: code:
huhu fucked around with this message at 15:13 on Jun 16, 2017 |
# ¿ Jun 16, 2017 15:08 |
|
Does anyone have a suggestion for a tutorial that walks through the basics of sockets up to putting it on a server and being able to type in "huhu.com/index.html" and get a page to load? I've got something basic running locally but would like to explore sockets, wsgi, and related topics more in depth.
|
# ¿ Jun 22, 2017 19:04 |
|
I've been using a script for a while now to launch my flask apps in debug mode.code:
code:
quote:I got the same error while developing a flask application. To solve the problem, I had to change the environmental variable from "FLASK_DEBUG=1" to "FLASK_DEBUG=0". The reason being that turning debugging on leads to threading errors. I got the solution after reading this blog Where "this blog" points to http://azaleasays.com/2014/05/01/django-logging-with-rotatingfilehandler-error/ Any ideas what might have triggered this error to start popping up?
|
# ¿ Jul 6, 2017 16:41 |
|
Loezi posted:What's the easiest library to make a GUI with, given that I require hassle-free licensing (which rules out PyQt)? Flask is also very nice.
|
# ¿ Jul 30, 2017 04:00 |
|
Edit: nevermind.
|
# ¿ Aug 3, 2017 17:36 |
|
I'm looking to start a pretty large Python project with the hopes of actually releasing it. The last time I tried this I failed pretty badly and have learned a bit but would love any suggestions before jumping in again. My thoughts thus far are to try and diagram the entire project, use a virtualenv, and document everything as best I can as I go. Any other suggestions?
|
# ¿ Sep 16, 2017 21:40 |
|
creatine posted:Does anybody know of a python3 module that let's you work with .FCS files? All the ones I can find are 2.7 only Perhaps you could do a .FCS -> .txt with another tool and go from there? If .FCS doesn't have formatting, you could probably just do with open - http://www.pythonforbeginners.com/files/with-statement-in-python
|
# ¿ Sep 28, 2017 02:56 |
|
Hughmoris posted:What Python books (if any) do you all have? I'm thinking about picking up Fluent Python and Effective Python. Are you just starting out? Automate the Boring stuff is a great starting point.
|
# ¿ Oct 21, 2017 21:14 |
|
|
# ¿ Apr 29, 2024 15:19 |
|
Trying to build a basic website with Django or Flask is a good way to get into backend/full stack development if you're interested in that kind of thing. When you can hookup the stuff you build with Python to a website - a whole world of awesome possibilities opens up. For Flask I recommend this tutorial - https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world And the accompanying book. For Django I'd recommend - https://docs.djangoproject.com/en/1.11/intro/
|
# ¿ Oct 22, 2017 01:47 |