flask-babylonjs
A Python Flask application with Babylon.js 3D scenes
Open this URL with https://github.dev/ instead of https://github.com/ to use the Visual Studio Code web-based IDE.
Run this application as follows:
- Enter
flask_appdirectory:$ cd flask_app - If non-existent, create a virtual environment inside the
flask_appdirectory:$ python3 -m venv .venv(macOS:$ virtualenv .venv)
In case of the following, follow its advice:
The virtual environment was not created successfully because ensurepip is not available.
On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.
sudo apt-get update
sudo apt install python3.10-venv
You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment.
On macOS see https://sourabhbajaj.com/mac-setup/Python/virtualenv.html
- Start the virtual environment and enter:
. .venv/bin/activate(macOS:source .venv/bin/activate) - Run
$ pip install -r requirements.txt - Run:
$ cd appthen$ npm installfinally$ cd .. - Set the Flask App to app directory:
(.venv) $ export FLASK_APP=app - Set the Flask Environment to True for development:
(.venv) $ export FLASK_DEBUG=True - Set the SQLAlchemy Database URI:
(.venv) $ export SQLALCHEMY_DATABASE_URI=..., default issqlite:///app.db - Set SQLAlchemy Track Modifications:
(.venv) $ export SQLALCHEMY_TRACK_MODIFICATIONS=True - Set Secret Key:
(.venv) $ export SECRET_KEY=******** - Run the flask app:
(.venv) $ flask run(.venv) $ python3 run.py - Open the web interface as prompted
- Use
CTRL+cto exit the web server. - Alternatively run the flask command line interface:
(.venv) $ flask shell - Execute any flask commands: >>>
- Use
exit()to exit from the command line interface.
In general, you can take the following steps to manage your database migrations as you develop your Flask applications:
-
Modify the database models.
-
If no
migrationsdirectory yet exists in theflask_appdirectory, run(.venv) flask_app $ flask db init. -
Generate a migration script with the
flask db migrate -m "some comment"command. If there have been no changes since last migration, you will be prompted withNo changes in schema detected.. Hence, you can repeat this command without fear. -
Review the generated migration script and correct it if necessary.
-
Apply the changes to the database with the
flask db upgradecommand. -
To restore a previous database version, use the
flask db downgradecommand.
See README.md
See README.md
See README.md
See README.md