<div dir="auto">A great way to have external services (Slack, Twilio, etc.) interact with your code during development is to use a service like <a href="https://ngrok.com">https://ngrok.com</a> <div dir="auto"><br></div><div dir="auto"><br><div data-smartmail="gmail_signature" dir="auto"><br>__<br>Corey</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 27, 2018, 5:52 PM Ernst, Kevin (ernstki) <<a href="mailto:ernstki@mail.uc.edu">ernstki@mail.uc.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Mike,<br>
<br>
You're probably already clear on this first part (the definition of a <br>
web server), but just to lead up to the explanation of why you need <br>
Flask for the demo app: a web server in this sense is a thing that runs <br>
one or more web applications, presents the "user interface" to those <br>
application as web pages to users' web browsers, and responds to users' <br>
interactions with those web pages.<br>
<br>
If you're familiar with HTML at all, you might know that you can <br>
double-click a .html file on your PC and that will open up in a web <br>
browser. That's called a "static" web page. No web server was <br>
necessarily required to deliver that to your browser, the web browser <br>
just opened the file off your hard drive. However, serving "static" web <br>
pages over a public URL on the Internet is one thing that web servers <br>
(in the Apache sense) can do.<br>
<br>
One other thing that a web server can do is to receive messages which <br>
represent users' interactions with the web pages it's responsible for <br>
serving, then communicate those interactions with *other* programs <br>
running on that computer (or another one), programs which are interested <br>
in performing actions based on those users' interactions. Like sending a <br>
password reset email, or fulfilling an order from an online checkout system.<br>
<br>
This is where you start hearing terms like "dynamic web pages," Ajax, <br>
and that sort of thing. You can add a <button> tag to a raw .html file, <br>
and the web browser will display that button, but the back-and-forth <br>
exchange of information that would happen when you *click* that button <br>
(e.g., fetching records from a database, submitting a credit card <br>
payment) happens by communicating with a web application, running on a <br>
web server.<br>
<br>
Now just expand the notion of "users' interactions" to also include web <br>
applications on the Internet communicating with each other. Like a Slack <br>
"bot" communicating with the Slack(.com) servers in order to post <br>
messages in a specific chat room / channel / whatever Slack calls them.<br>
<br>
This is where Flask comes in.<br>
<br>
Flask is a library that makes it easy to create a web application, <br>
which, when exposed to the public Internet, the Slack.com servers could <br>
communicate with in order to create notifications in Slack chat rooms.<br>
<br>
The sample code you found (the 'python-message-menu-example' project on <br>
GitHub) does exactly that--good find! When that project's README says <br>
"endpoints" for this or that, it means the Flask-based web application, <br>
exposed to the public Internet, for the Slack.com servers to communicate <br>
with. And in this case, the web application that creates those <br>
"endpoints" is referred to more specifically as a Slack "bot." And <br>
that's "bot" in the old Internet Relay Chat sense of a program that <br>
posts to a chat room in response to users' interactions, even though <br>
writing a program to do such a thing, in 2018, is a little more <br>
convoluted than it was, say, in 1998.<br>
<br>
Flask is also relatively popular because it includes its own lightweight <br>
"development server," a built-in web server, which can simplify the <br>
process of getting simple, low-volume web applications up-and-running, <br>
because it absolves you the complexity of running Apache or Gunicorn, or <br>
really any other software except for Python.<br>
<br>
There are lots of reasons why you *might* choose to run your <br>
Python-plus-Flask web application within a high-performance web <br>
application server environment like Apache with mod_wsgi or Gunicorn, <br>
rather than using the Flask development server, but for this little <br>
Slack bot application, those reasons don't apply to you.<br>
<br>
The thing is, for this 'python-message-menu-example' Slack bot to work, <br>
the Flask "application" (in the sense of the "endpoints" for Slack.com <br>
to communicate with) would need to run on a computer with more-or-less <br>
direct access to the Internet. As in the ability to expose <br>
communications ports to other clients on the public Internet. You are <br>
likely to have problems trying to get the bot to communicate with <br>
Slack(.com) unless you are ready to mess with your wifi router's settings.<br>
<br>
If you're not able to run this Flask app on a publicly-accessible <br>
server, maybe one that your friend has access to, I recommend looking <br>
into the hosting service <a href="http://pythonanywhere.org" rel="noreferrer noreferrer" target="_blank">pythonanywhere.org</a>.<br>
<br>
Hope this helps.<br>
<br>
--Kevin<br>
<br>
<br>
P.S.<br>
<br>
Since I'm replying to a Mailman digest, it's likely this reply isn't <br>
going to show up inside the original message thread in the archives[1]. <br>
Sorry 'bout that.<br>
<br>
[1]: <a href="https://mail.python.org/pipermail/flask/2018-September/thread.html" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/pipermail/flask/2018-September/thread.html</a><br>
<br>
<br>
On 9/27/18 12:00 PM, <a href="mailto:flask-request@python.org" target="_blank" rel="noreferrer">flask-request@python.org</a> wrote:<br>
> <br>
> thanks, all.<br>
> <br>
> I know this isn't purely a Flask question, but I think it's closely related<br>
> or will help me understand Flask. If this is completely off-topic, please<br>
> ignore.<br>
> <br>
> What I'm not clear on... how do I get this demo app (Flask + Slack) to<br>
> work? Am I supposed to host a Slack server or an Apache server or something<br>
> like that on my local machine, or does this work with <a href="http://slack.com" rel="noreferrer noreferrer" target="_blank">slack.com</a>, or<br>
> something else? Is there something about using Flask that I supposed to<br>
> understand?<br>
> <br>
_______________________________________________<br>
Flask mailing list<br>
<a href="mailto:Flask@python.org" target="_blank" rel="noreferrer">Flask@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/flask" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/flask</a><br>
</blockquote></div>