Forums

alternative ports i can use with flask

When using a different port than the default (:80) i always get socket binding errors (like [Errno 13] Permission denied).

Which ports can be used with Flask and a free account?

Also, can i have different apps running on different ports at the same time?

You don't need to run your app and specify a port. Instead, our servers will use your wsgi.py to serve your webapp directly at say eadmaster.pythonanywhere.com for you.

In fact, the machine that your bash console etc is running on will be different from the machine that your actual webapp is being served from.

Oh, i see now the url in the dashboard for the wsgi.py.

Now, to change the listening port i should add something like:

app.config['SERVER_NAME'] = "0.0.0.0:1234"
app.config['DEBUG'] = True

?

btw, what is the purpose of the flask_app.py file then? Should i leave it empty?

Just to clarify what Conrad was saying -- on PythonAnywhere you can't specify a port. For a free account, you get one website, which is served over HTTP on port 80 and over HTTPS on port 443. Paid accounts can also have web sites on custom domains (purchased elsewhere, we're not a registrar), but again only on the standard HTTP and HTTPS ports.

The purpose of the WSGI file is to connect your domain to a specific web app, whether that app is Flask, Bottle, Django, web2py, or another WSGI-compliant framework. These frameworks all have a fairly simple way to produce a WSGI application, so that's what you put there. The rest of your website code is assumed to be kept in a file somewhere in your home directory -- by default we generate a simple "Hello world" app for you, which for Flask is flask_app.py, but that's just a stub for you to replace with your real Flask code.