Host a Flask server
WayScript X allows you to configure your Lair to host a Flask app in minutes.

Create app.py or load Flask files

Use the boilerplate code below to create a app.py file in your Lair’s root directory. Or if you have an existing Flask project, copy or clone your project files into your Lair’s directory. See File system for more details on how to manipulate files in your workspace file system.

Boilerplate app.py

1
# my-lair-a > app.py
2
3
from flask import Flask
4
5
app = Flask(__name__)
6
7
@app.route('/')
8
def hello_world():
9
return 'Hello World'
10
11
if __name__ == '__main__':
12
app.run()
Copied!

Add packages to requirements.txt

Create a requirements.txt file in your Lair’s root directory and specify the flask package. You can also specify any additional dependencies your app requires. See Hosted environments for more details.
1
# my-lair > requirements.txt
2
flask==2.0.1
Copied!

Configure deploy trigger

Open your Lair’s .triggers file and add a new deploy trigger. Create a name for your trigger and input the following run command and port number 8080 (or modified command and port number based on your app requirements). See Triggers for more details.
1
flask run --port 8080 --host 0.0.0.0
Copied!

Test app in development environment

Press “Run” to execute the run command and start your web server process (see Processes for more details). Navigate to the *.wayscript.cloud endpoint generated to see your Flask app in action!
Set your FLASK_ENV=development to enable hot reload of your server process when modifying your app’s files.

Deploy to production environment

Once you have finished testing, press “Deploy” to create a production environment for your Flask app. Select <Lair_name>.prod in the Lair selector menu and view the on deploy trigger to access your app’s production endpoint. See Hosted environments for more details.
Last modified 7d ago