Forums

Advice needed regarding Flask vs Bottle and AJAX

I have written a console app in Python that interacts with a web site by submitting forms and scraping pages. I would like to convert it to a web page that performs the same actions when buttons are clicked. I have never created a web page like this before. I gather that combining Ajax (again, no experience with this) with the Flask or Bottle framework is the approach that I should take. Am I on the right track? Should I choose Flask or Bottle? Is there a good example that I can follow? Thanks, in advance.

AJAX with either Flask or Bottle is a great solution for the kind of thing you're trying to do. TBH which you'd choose is very much a case of personal preference, and I wouldn't recommend one over the other. I will say that we use Flask for most of our internal microservices and we're very happy with it -- but I'm sure we'd also be equally happy with Bottle. Perhaps I should recommend Flask just because if you're building your app on PythonAnywhere, we'd be able to give better tech support because we're more familiar with it :-)

On the AJAX side, most people use a JavaScript framework that wraps up the details of client/server communication and dynamic HTML generation these days. Good options right now are React, Vue and Angular 2 (not Angular 1) -- though it's worth noting that JavaScript frameworks are very much in a state of flux, and in six months' time the fashion will probably have moved on to something else... Again, I can't give definite recommendations as to which of the current frameworks is objectively "best", though I can say that we're using React and are, again, very happy with it.

Regarding examples -- we're big fans of the "Real Python" tutorials, and they have one for Flask and React that looks pretty solid.

Thanks for the great information and links!!

Glad to help :-)