Hi all
Not sure whether this list is the right one, but I have a question about running a small Python Flask web on tilde.club.
I saw that Python 3.8 is installed on tilde.club, so I created a virtualenv and got all the dependencies for the app. So far so good.
I can even run the app on the Flask-built-in server and the app says that it "is running on http://127.0.0.1:8050/%E2%80%9C, but obviously I cannot make tilde.club’s whole underlying web server make listen on port 8050!
So, I am curious how I could run that flask webapp, so that it can be accessed from the outside through a subpath of my homepage www.tilde.club/~halloleo/, for example http://www.tilde.club/~halloleo/flask.
Maybe this is a silly question, but I really have no idea how to do this.
Happy web hacking, ~halloleo
On Wed, 28 Oct 2020, leo wrote:
I can even run the app on the Flask-built-in server and the app says that it "is running on http://127.0.0.1:8050/?, but obviously I cannot make tilde.club's whole underlying web server make listen on port 8050!
User processes can open a [random wild port] to listen, yes; but such port cannot be connected from outside- only from inside the club. Accessing such port from outside would simply result in connect timeout.
So, I am curious how I could run that flask webapp, so that it can be accessed from the outside through a subpath of my homepage www.tilde.club/~halloleo/, for example http://www.tilde.club/~halloleo/flask.
As far as I know, the club is not configured to allow this. For an authoritative answer, wait for ~ben's and/or ~deepend's reply.
Regards, ~xwindows
To my understanding, running a traditional server-side web app is at odds with the original principle of tilde—it’s not just another server, it’s a server bound by the creative constraint of an architecture that serves only static pages to the public internet. There are still lots of ways to make your page dynamic, like building your app all on the front end, or adding a cronjob that updates or generates pages on a schedule rather than in response to a request. What’s the goal of your flask app, Leo?
~brendn
On Oct 28, 2020, at 1:30 AM, xwindows xwindows@tilde.club wrote:
On Wed, 28 Oct 2020, leo wrote:
I can even run the app on the Flask-built-in server and the app says that it "is running on http://127.0.0.1:8050/?, but obviously I cannot make tilde.club's whole underlying web server make listen on port 8050!
User processes can open a [random wild port] to listen, yes; but such port cannot be connected from outside- only from inside the club. Accessing such port from outside would simply result in connect timeout.
So, I am curious how I could run that flask webapp, so that it can be accessed from the outside through a subpath of my homepage www.tilde.club/~halloleo/, for example http://www.tilde.club/~halloleo/flask.
As far as I know, the club is not configured to allow this. For an authoritative answer, wait for ~ben's and/or ~deepend's reply.
Regards, ~xwindows
Hello,
Unfortunately there is no way for us to be able to do that without changing our server configs. Which if we did a change like that for 1 user we would have to do it for all users which would make it not administratively viable. As much as we don’t mind users running small low resource processes in the background. They would only be accessible from the tilde itself.
Thanks ~deepend
On Oct 27, 2020, at 11:53 PM, leo halloleo@tilde.club wrote:
Hi all
Not sure whether this list is the right one, but I have a question about running a small Python Flask web on tilde.club.
I saw that Python 3.8 is installed on tilde.club, so I created a virtualenv and got all the dependencies for the app. So far so good.
I can even run the app on the Flask-built-in server and the app says that it "is running on http://127.0.0.1:8050/%E2%80%9C, but obviously I cannot make tilde.club’s whole underlying web server make listen on port 8050!
So, I am curious how I could run that flask webapp, so that it can be accessed from the outside through a subpath of my homepage www.tilde.club/~halloleo/, for example http://www.tilde.club/~halloleo/flask.
Maybe this is a silly question, but I really have no idea how to do this.
Happy web hacking, ~halloleo
On 29 Oct 2020, at 6:27, deepend wrote:
As much as we don’t mind users running small low resource processes in the background. They would only be accessible from the tilde itself.
~deepend, does ~cosarara’s smart idea of proxying the request to the inside comply with the guidelines here?
Thx ~halloleo
hello,
It doesn't bother me as long as the resource usage is low. Just need to be mindful that the system only has so many resources and many users.
Thanks
~deepend
On 2020-10-28 9:42 p.m., leo wrote:
On 29 Oct 2020, at 6:27, deepend wrote:
As much as we don’t mind users running small low resource processes in the background. They would only be accessible from the tilde itself.
~deepend, does ~cosarara’s smart idea of proxying the request to the inside comply with the guidelines here?
Thx ~halloleo
I seem to be really bad at sending email, since I sent this same email this morning to the list and yet it seems it got lost. Trying again, this time from mutt.
See https://tilde.club/~cosarara/flask/ for a proof of concept using https://github.com/michaelfranzl/no.php as a reverse proxy.
I saved no.php as index.php and edited it to the following config:
$backend_url = "http://localhost:4455/"; $backend_info = parse_url($backend_url); $host = $_SERVER['HTTP_HOST']; $request_uri = $_SERVER['REQUEST_URI']; $uri_rel = "~cosarara/flask/"; # URI to this file relative to public_html $request_includes_nophp_uri = false;
And ran flask with --port=4455, of course.
Happy hacking, ~cosarara
On 29 Oct 2020, at 8:03, Jaume wrote:
See https://tilde.club/~cosarara/flask/ for a proof of concept using https://github.com/michaelfranzl/no.php as a reverse proxy.
I saved no.php as index.php and edited it to the following config:
Super cool! Very smart!
Thx ~halloleo
On Wed, Oct 28, 2020 at 04:55:37PM +1100, leo wrote:
Not sure whether this list is the right one, but I have a question about running a small Python Flask web on tilde.club.
This is a bit of a necropost, but tilde.club supports CGI, and Python's built-in wsgiref module supports serving WSGI applications (such as a Flask application) using CGI.
You can test that CGI works for you like so:
$ mkdir -p ~/public_html/cgi-bin $ cat > ~/public_html/cgi-bin/test.cgi #!/usr/bin/env python3 print("Content-Type: text/plain\n") print("I'm a CGI script!") ^C $ chmod +x ~/public_html/cgi-bin/test.cgi
You should now be able to access the CGI script from the web.
Writing a script to serve your site once you know that works is easy enough.
#!/usr/bin/env python3 from wsgiref.handlers import CGIHandler
# A simple, bare-bones, WSGI application. def simple_app(environ, start_response): status = "200 OK" headers = [("Content-Type", "text/plain")] start_response(status, headers) return [b"Hello, world!"]
CGIHandler().run(simple_app)
I have a demo of that running at https://tilde.club/~talideon/cgi-bin/test.cgi if you want to take a look. You can substitute `simple_app` with a reference to the object in your application generated with `app = Flask(__name__)`, as that should be a WSGI application object. Mind you, don't expect it to be fast, and you might have some weirdness when it comes to URL paths!
K.
On 26 Apr 2021, at 6:46, talideon@tilde.club wrote:
This is a bit of a necropost,
Yes, it is indeed.😉 (However dumb me I had to look up the word “necropost”…)
but tilde.club supports CGI, and Python's built-in wsgiref module supports serving WSGI applications (such as a Flask application) using CGI.
Hey, that’s cool! Will try it out. Thanks!
~halloleo
tildeclub@lists.tildeverse.org