Python based adventure game, played on a web page

I have written a text adventure game using Python. Very much like Zork, or Colossal Cavern. It currently runs in a terminal. I would like to make it available to play from a web site. It uses ANSI color and position codes in the print statements. It opens .txt data files and reads from them to parse information. It opens files to save user data. Is it possible to run this on my existing domain?

Welcome to the Anvil Community Forum!

Anvil does let you run Python code in the browser, but otherwise, the code’s execution environment is very different from a desktop computer’s. Simply put, browsers offer a very different (and incompatible) set of features.

The browser’s built-in security features will get in your way in the following areas:

For security reasons, code running in a browser is not allowed to access the user’s files, except by explicit permission (e.g., upload and download) from the user.

Also, modern browsers use a very different display model, based on pixels, not on a terminal’s character cells. There is no built-in support for using “ANSI color and position codes.”

Workarounds are certainly possible. In place of files, Anvil supports a tabular database. And you might find a third-party terminal emulator that can run inside the browser, to emulate the terminal behavior (interpreting ANSI codes). This is not the sort of thing most folks would want to re-create from scratch.

In short, a web browser using Anvil does not look like a great fit for your program as written. Not to me, anyway.

But Anvil is not the only way to run Python in a browser. And some of the alternatives might be a better fit. Here’s a blog post where some of the options are discussed:

Edit: Also consider repl.it