![](https://framerusercontent.com/images/Mey03e9hkZzD8JrMn6E1KTFZHY.png)
![](https://framerusercontent.com/images/Mey03e9hkZzD8JrMn6E1KTFZHY.png)
![](https://framerusercontent.com/images/Mey03e9hkZzD8JrMn6E1KTFZHY.png)
Hosting Python Flask Applications as a service on Ubuntu Linux Server
Hosting Python Flask Applications as a service on Ubuntu Linux Server
Hosting Python Flask Applications as a service on Ubuntu Linux Server
Let us explore how to run Python Flask application as a Linux Service.
![](https://framerusercontent.com/images/kXthFdgtyhqaK9IhoM9dTXvKYuc.png)
Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service
![](https://framerusercontent.com/images/B2WxyMpcLYVC8dNhtWQhMdL4OOg.png)
2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target
![](https://framerusercontent.com/images/yHLwQk1nQxrMkIdkfqTBXqYQdx4.png)
service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva
![](https://framerusercontent.com/images/WemnrcJtnba2E8r5SKIZWXq5wE.png)
5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva
![](https://framerusercontent.com/images/6S0MV7K5RRNPynHIcGODFNo8Zw.png)
6. Now to restart the service, we have a command:
sudo systemctl restart riiva
![](https://framerusercontent.com/images/th00T2uiJMOe89BHIQY8jqyZc.png)
Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva
![](https://framerusercontent.com/images/ZpDhLRWwxjEFQHJEJzXAi0PxsQ.png)
Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.
Let us explore how to run Python Flask application as a Linux Service.
![](https://framerusercontent.com/images/kXthFdgtyhqaK9IhoM9dTXvKYuc.png)
Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service
![](https://framerusercontent.com/images/B2WxyMpcLYVC8dNhtWQhMdL4OOg.png)
2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target
![](https://framerusercontent.com/images/yHLwQk1nQxrMkIdkfqTBXqYQdx4.png)
service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva
![](https://framerusercontent.com/images/WemnrcJtnba2E8r5SKIZWXq5wE.png)
5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva
![](https://framerusercontent.com/images/6S0MV7K5RRNPynHIcGODFNo8Zw.png)
6. Now to restart the service, we have a command:
sudo systemctl restart riiva
![](https://framerusercontent.com/images/th00T2uiJMOe89BHIQY8jqyZc.png)
Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva
![](https://framerusercontent.com/images/ZpDhLRWwxjEFQHJEJzXAi0PxsQ.png)
Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.
Let us explore how to run Python Flask application as a Linux Service.
![](https://framerusercontent.com/images/kXthFdgtyhqaK9IhoM9dTXvKYuc.png)
Let’s follow the below steps :
In order to deploy a service on Ubuntu server we need to create a file (name of the service : riiva) :
sudo nano /etc/system/system/riiva.service
![](https://framerusercontent.com/images/B2WxyMpcLYVC8dNhtWQhMdL4OOg.png)
2. Now, use the following caption :
[Unit] section:
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/riva-stremingserver/
Environment=”PATH=/home/ubuntu/stream/bin”
ExecStart= gunicorn — bind 0.0.0.0:9501 -k flask_sockets.worker app:app
[Install]
WantedBy=multi-user.target
![](https://framerusercontent.com/images/yHLwQk1nQxrMkIdkfqTBXqYQdx4.png)
service file
3. Here the following terms included :
User:- The user is defined as the current user.
Group:- the user is in which group of linux.
WorkingDirectory:- It refers to the directory which you want to be worked on.
Environment:- It the takes the path of env where it can be run.
ExecStart:- It refers to the command which you want to execute.
4. After this, to start this service we have a command:
-> sudo systemctl start riiva
![](https://framerusercontent.com/images/WemnrcJtnba2E8r5SKIZWXq5wE.png)
5. In order to see the status of logs of this service, we have a command:
sudo systemctl status riiva
![](https://framerusercontent.com/images/6S0MV7K5RRNPynHIcGODFNo8Zw.png)
6. Now to restart the service, we have a command:
sudo systemctl restart riiva
![](https://framerusercontent.com/images/th00T2uiJMOe89BHIQY8jqyZc.png)
Your application is hosted upon HTTP://IP-ADDRESS:9501
7. Finally, to end this service, we have a command:
sudo systemctl stop riiva
![](https://framerusercontent.com/images/ZpDhLRWwxjEFQHJEJzXAi0PxsQ.png)
Congratulations, You are done with the hosting.
For any further queries or anything related to Python Development, Coding, Blogging, Tech Documentation you can DM me on Linkedin or instagram at id=acanubhav94.