How can I build an updater for a flask application? - python

I'm building an internal only flask-based application for work. I would like the program to update automatically from the master branch of my git repository. The application is running on a Linux based (Ubuntu server) VM. Is there a way to get the flask app to automatically pull changes and update from the master branch?
Edit: I don't want a python module updater from pip/git (most common search result)
Update: I found a module called micropython-ota-updator, the problem with this is it seems to update on reboots. The software I'm building is meant to consistently stay up. My inital idea was to check for updates at a interval.

For anyone else having this issue:
I decided on dynamically generating GitHub links and building a function for cloning the repo. There were also some configuration files that get saved outside of the repo before cloning. Once the repo is cloned, the configuration files are moved back into their proper places in the new repo. If anyone else wants more information about this, let me know. I'm glad to share my discoveries!

Related

Check for updates of a folder in repository automatically in each run in python

I wanted to know how popular tools update their folders automatically when running tool locally. I wanted to explain a scenario in this below way.
Tool I wanted to run - example
Tool GitHub repo contains a directory (rules) that I want to check if there is any update, if there is any update then download the rules folder locally and tool continues to run.
I hope you got the question.

If I deploy my Twitch bot made in python on Heroku using github when the variables get edited while being used does that reflect in the github code?

I have a variable and a .txt file that are updated via commands in Twitch chat. The bot is made in python. One being a counter that gets added to every time someone does a specific command. Does the counter variable get updated within the code on Github that I am able to see it when checking the code?
Another command adds new words to a .txt file, when someone performs the command to add something would that get added to the .txt file on Github as well or only within the heroku app.
I have tried performing commands but it seems like when I update the counter or add to the .txt it doesn't reflect in github. Is there a way to make it reflect?
Those resources are generated or updated during the execution of your program (here, an Heroku application), which means, by default, their updates are not tracked under source control (in the Heroku app execution environment context), so not visible in GitHub.
You would need, from your application to call a GitHub Action (pipeline executed on GitHub side), like action-update-file, in order to fetch (curl) and then update your files in your GitHub repository.
See "How to trigger a Github action with an HTTP request" (from Riku Rouvila) for a practical example of calling a GitHub Action from a program.

Error in deployment of a flask web app with MongoDB Atlas

i am new in developing web apps so i might get confused a lot of times!
The problem is this:
I was developing with Pycharm son sort of basic social network, and at first when you sign up the users were created in local folder as JSON files and then i look foward to make a deployment, and i did it without problem using PythonAnywere (PA). Lets call my .py file "server.py" where i have the whole thing.
Then i started looking for some cloud service and I ended modifying everything in order to work with Mongodb Atlas and it was a complete success. I made a lot of local test using Pycharm and everything is OK, the users are now created on cloud service.
My problem is that i would like to make a deployment test with that Mongodb service version, and i was trying to use (PA) again but this time its give me a lot of errors.
Note: i already install all the requirements in (PA) from pip freeze requirements.txt
Is there a problem with PA and MongoDB? is ther any other better option?
Should it run ok if the first version of "server.py" was ok?
I just replaced that file with new one, that was runnning perfect on localhost.
If you need more info just tell me, i am very new in this.
Thanks a lot

Azure container instance with git redeployment scheme similar to Azure Web Service

I want to run a python script continuously on a container instance. I could create a docker container and update my private registry, but it seems like overkill to have to make a new image every time I change the source code. I like how Azure WebApps can link to a git repo and automatically sync the source when it is updated and re-deploy the app. Is it possible to do something similar like this out of the box without making a python web app (non-flask, etc)?
I could technically run my script in flask and just have the web server do nothing (or even close the port) but this seems unnecessary.
Is it possible to do something similar like this out of the box without making a python web app (non-flask, etc)?
I am afraid there is no such out of box way to resolve this question.
Rebuilding image when the code changes is the canonical approach. Build the python script continuously with container instance is different from the Azure WebApps. We have to update the image to the docker container so that could be updated to the private registry.
Besides, if we build/deploy pythonApp with private agent, it is not wasteful at all if done right. pythonApp code should be COPY'd into your image as the final step. This means rebuilding will be very fast as all other steps will be cached. If you only have a few kB of source code changes it will only result in a single new layer of a few kB. Stopping and starting containers is also very light weight. There is nothing to worry about in following this approach.
But, for the hosted agent, it is indeed a problem. There is a user voice on Developer Community and a topic on github about it.
Hope this helps.

Do you work directly in the Github respository folder?

I recently started using Github and was wondering if I should be working directly in the Github repository folder, or working in a different folder and then adding new files to the repository later?
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere and you can create one branch for you and update it to master branch.

Categories