In this world of the internet, there often comes a time that you write a script or a program that needs to be deployed as a website or a web app, doing this without the prior background in the field can be difficult and at times demotivating.
Presenting to you STAR. With STAR in a few steps you can convert you application into a website or run it from discord, yes the discord we all love.
STAR currently only works for unix based systems namely linux/mac, I haven't tried it on windows pull requests are welcome
STAR can be run in 2 forms web app or via discord and if you are fancy enough both at the same time, the number of steps remains the same.
This is just the web app
Download STAR_web
This is just the discord bot
Download STAR_bot
This has both the web app and the bot
Download STAR
Once you have downloaded the tar.gz extract it into a folder
Your direcory structure will look something like this
We will get back to this
Next step is installing redis
Redis is most probably in your distribution's package manager
If you do not find it in your distribution's package manager you can always get it from it's website http://redis.io
While that is happening lets go to the next step
Make sure you are running python3.x
If you are running some kind of virtual environment now is the time to be in it.
That will install all the requirements.
If you have are planning on using the bot you need to get a api_key from discord for you bot it's pretty simple.
How to make a discord bot. This post explains step by step how to get an api key for your discord bot.
Once you have the api key put it in the .env file
We are one step away from deployment
if you open up the main.py file you will find this
This is where you drop the code you want to run
You can put multiple functions in the file, main can call other functions or files, basically any valid python3.x function will work.
Once you put in the code lets get to the tricky part, say you are writing a monte carlo simulation to calculate the ratio of are under the inside a quarter of the circle and the square
Do not worry if you do not understand the math, this is about the parameters and the functions. Your code will look something like this.
Now we will be using type annotation on our main function's parameters. Which basically means that we will write the type of the parameters in front of the paramter like so.
and we are done, now to deployment
Open up a terminal and go in the folder where the file was extracted and run the deploy.sh bash script
If everything goes right and you have some luck on your side you will see a stream of text flowing ignore it. In about 10 seconds that will have been deployed.
If you are running the web app it will be hosted at http://localhost:8000/
If you downloaded the bot as well then open up discord and your server and type in help it will guide you through the commands on how to use it.