[Flask] Need pointers to general introduction to web, frameworks

Ernst, Kevin (ernstki) ernstki at mail.uc.edu
Thu Sep 27 17:51:42 EDT 2018


Hi Mike,

You're probably already clear on this first part (the definition of a 
web server), but just to lead up to the explanation of why you need 
Flask for the demo app: a web server in this sense is a thing that runs 
one or more web applications, presents the "user interface" to those 
application as web pages to users' web browsers, and responds to users' 
interactions with those web pages.

If you're familiar with HTML at all, you might know that you can 
double-click a .html file on your PC and that will open up in a web 
browser. That's called a "static" web page. No web server was 
necessarily required to deliver that to your browser, the web browser 
just opened the file off your hard drive. However, serving "static" web 
pages over a public URL on the Internet is one thing that web servers 
(in the Apache sense) can do.

One other thing that a web server can do is to receive messages which 
represent users' interactions with the web pages it's responsible for 
serving, then communicate those interactions with *other* programs 
running on that computer (or another one), programs which are interested 
in performing actions based on those users' interactions. Like sending a 
password reset email, or fulfilling an order from an online checkout system.

This is where you start hearing terms like "dynamic web pages," Ajax, 
and that sort of thing. You can add a <button> tag to a raw .html file, 
and the web browser will display that button, but the back-and-forth 
exchange of information that would happen when you *click* that button 
(e.g., fetching records from a database, submitting a credit card 
payment) happens by communicating with a web application, running on a 
web server.

Now just expand the notion of "users' interactions" to also include web 
applications on the Internet communicating with each other. Like a Slack 
"bot" communicating with the Slack(.com) servers in order to post 
messages in a specific chat room / channel / whatever Slack calls them.

This is where Flask comes in.

Flask is a library that makes it easy to create a web application, 
which, when exposed to the public Internet, the Slack.com servers could 
communicate with in order to create notifications in Slack chat rooms.

The sample code you found (the 'python-message-menu-example' project on 
GitHub) does exactly that--good find! When that project's README says 
"endpoints" for this or that, it means the Flask-based web application, 
exposed to the public Internet, for the Slack.com servers to communicate 
with. And in this case, the web application that creates those 
"endpoints" is referred to more specifically as a Slack "bot." And 
that's "bot" in the old Internet Relay Chat sense of a program that 
posts to a chat room in response to users' interactions, even though 
writing a program to do such a thing, in 2018, is a little more 
convoluted than it was, say, in 1998.

Flask is also relatively popular because it includes its own lightweight 
"development server," a built-in web server, which can simplify the 
process of getting simple, low-volume web applications up-and-running, 
because it absolves you the complexity of running Apache or Gunicorn, or 
really any other software except for Python.

There are lots of reasons why you *might* choose to run your 
Python-plus-Flask web application within a high-performance web 
application server environment like Apache with mod_wsgi or Gunicorn, 
rather than using the Flask development server, but for this little 
Slack bot application, those reasons don't apply to you.

The thing is, for this 'python-message-menu-example' Slack bot to work, 
the Flask "application" (in the sense of the "endpoints" for Slack.com 
to communicate with) would need to run on a computer with more-or-less 
direct access to the Internet. As in the ability to expose 
communications ports to other clients on the public Internet. You are 
likely to have problems trying to get the bot to communicate with 
Slack(.com) unless you are ready to mess with your wifi router's settings.

If you're not able to run this Flask app on a publicly-accessible 
server, maybe one that your friend has access to, I recommend looking 
into the hosting service pythonanywhere.org.

Hope this helps.

--Kevin


P.S.

Since I'm replying to a Mailman digest, it's likely this reply isn't 
going to show up inside the original message thread in the archives[1]. 
Sorry 'bout that.

[1]: https://mail.python.org/pipermail/flask/2018-September/thread.html


On 9/27/18 12:00 PM, flask-request at python.org wrote:
> 
> thanks, all.
> 
> I know this isn't purely a Flask question, but I think it's closely related
> or will help me understand Flask. If this is completely off-topic, please
> ignore.
> 
> What I'm not clear on... how do I get this demo app (Flask + Slack) to
> work? Am I supposed to host a Slack server or an Apache server or something
> like that on my local machine, or does this work with slack.com, or
> something else? Is there something about using Flask that I supposed to
> understand?
> 


More information about the Flask mailing list