Setup a Django Server (Python)
WayScript allows you to configure your Lair to host a running microservice in minutes. Follow this guide to setup a simple Django app in your Lair.
Create a
requirements.txt
file in your Lair’s root directory and specify the django package. You can install the django package via pip
in your Lair Terminal. You can also specify any additional dependencies your app requires. See Hosted environments for more details.pip install django
pip freeze > requirements.txt
django-admin startproject mysite
This creates your Django project
mysite
can be changed to whatever you want as a project nameOpen 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.python mysite/manage.py runserver 0.0.0.0:8080
ALLOWED_HOSTS = ['<DOMAIN_FROM_DEPLOY_TRIGGER>']
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!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.By default, your Lair's endpoints are protected against unauthenticated requests. See Endpoints on how to public expose your endpoints or authenticate using your application key.
Last modified 1mo ago