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.