Introduction: Running Web Frameworks on Anvil Cloud

This document introduces how to run Python-based web frameworks such as Flask, and Streamlit on the Anvil Cloud environment used in The Data Mine which can be accessed at: notebook.anvilcloud.rcac.purdue.edu. We will go over how to launch and preview a Flask or Streamlit app inside a notebook session.

Unlike other shared systems, Anvil Cloud provides isolated network ports for every user session. This eliminates the common issues students encounter on Anvil or local machines, such as port conflicts, blocked routing, or apps crashing because another process is already using the same port.

This introduction sets the foundation for building lightweight dashboards, interactive tools, and web-based interfaces directly inside your computational workspace Anvil Cloud, without needing any local installation.

Flask on Anvil Cloud

If you want to run Flask, Streamlit, or any other Python-based web framework, the recommended platform is notebook.anvilcloud.rcac.purdue.edu/ and open a terminal tab.

In order to start running flask you’ll need an app.py file. If you don’t already have one you can run this command below in the terminal to make your own app.py file:

echo 'from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

if __name__ == "__main__":
    app.run(debug=True)' > ~/app.py

Confirm the contents of the app.py file:

cat app.py

Run Flask:

flask run

When you run the app, Flask prints something like:

Running on http://127.0.0.1:5000

IMPORTANT: Do not try to open this URL directly in your laptop’s browser. 127.0.0.1 refers to your own computer, not the notebook server where Flask is running.Only the port number in this URL is important.

So if Flask prints:

Running on http://127.0.0.1:5000

Then open your app at:

https://notebook.anvilcloud.rcac.purdue.edu/user/x-YOUR-ACCESS-ID/proxy/5000/

NOTE: You must include the trailing slash /.

Running Streamlit on Anvil Cloud

Choosing Your Own Port to come back and Bookmark

You can specify your own port when launching Flask:

flask run -p 8000

Then open:

https://notebook.anvilcloud.rcac.purdue.edu/user/<YOUR-USERNAME>/proxy/8000/

Note: if the URL does not work after you bookmarked it, you most likely need to relaunch your notebook session.