How to prevent your free tier heroku app from idling(python/django) [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Is there any way, through code, to prevent your app from idling? I'm thinking something like what is being done here. How to do this through code, but in python/django as that is what my app is done in, i.e. what is the equivalent in python to Node's setInterval. What are the disadvantages of using a pinging service over doing it through code(other than if the site goes down your app wont get pinged). Can you recommend a good pinging service? Thanks in advance.

You cannot do it from within the application. It needs to be woken up "externally". This can be just another Heroku application but that kind of defeats the purpose. There are some Heroku add ons that allow you to monitor your website thus also pinging it in regular intervals.
For example:
https://elements.heroku.com/addons/newrelic
With this your website would always stay awake.
The article you linked is imo more complicated than necessary. If you own a VPS you could host your website there. You could also write a curl command save it as a shell script and call it from cron (https://help.ubuntu.com/community/CronHowto).

Related

A safe way to make an website run a python script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I made a small script that solves an combinatorial optimization problem and I would like put it in a website so users can "play" with it, they could send a list of "points" to the server and this script would use a database to return the best combination of these "points".
The problem is I do not have much experience in web dev. I searched how to make an html button execute an script and I found this thread: https://stackoverflow.com/questions/48552343/how-can-i-execute-a-python-script-from-an-html-button#:~:text=To%20run%2C%20open%20command%20prompt,Hope%20this%20helpful.
But there says that an html button calling an python script is not safe. So what would be ideal What would be an ideal, safe alternative so that I could make sure that anyone who accesses my website can execute this script safely?
Well, there's no "easy" answer to your question. What you'd really need to do is to create a web-site in Python on your host computer – using a tool such as Django – and have one of the URLs supported by that website call your script.
Honestly, "what you're asking for here, really isn't the sort of question that StackOverflow is intended to answer." It's too big. Another one of the SE-family sites might be more appropriate, although I'm not quite sure which one ...
The solution that comes to mind would be setting up some Python-API (e.g. with Flask) which you could call with HTTP via JS, having different routes for different usages.
Here's a short overview of Flask showcasing how it could be used.

Creating a simple python web application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a python script that takes inputs from commandline. I simply want to modify this script so I can run it on web. I want the commandline interface to be replaced by a simple boxes in a web page, and once the script is executed, I want the results to be shown on a webpage like it does in commandline.
Any help on where to start, which python packages to use and which steps to take would be much appreciated.
Until now, I read a little about webapp2 for Google App Engine and web.py. I do not want to use Django.
Thank you!
While you can use a microframework like Flask [1] for quickly getting started, you can get closer to the metal. Try learning about the HTTP protocol and implement your own server using the http module. Python 3's http.server contains a class SimpleHTTPServer [2] which can be very good for understanding how you're communicating between the client and your process.
[1] http://flask.pocoo.org/docs/0.12/quickstart/
[2] https://docs.python.org/2/library/simplehttpserver.html
Have you considered using Flask?
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
This is a pretty great tutorial on how to make a basic webapp.

How to run python web-crawler effectively [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a python web-crawler that get info and put it in SQL. Now I also have php page, that read this info from the SQL, and represent it. The problem is: in order that the crawler program to work, my computer has to stay 24/7 working. I have simple home computer- so its a problem. Does there is a diffrent way to run the web-crawler? Or do I have to run it on my pc?
If you are monitoring pages that get updated constantly then yes you will need to run it on some computer that is on 24/7. You can either use a cron job or a continuous loop (with some monitoring). If you don't want to run it on your home machine, I would recommend getting a free AWS account. You can get an EC2 micro instance which will allow you to run your python script and an S3 database instance which will allow you to store the information.
Here is a link to AWS

Easiest way to manage/monitor a flask app? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a small flask app I want to deploy on my server and I'd like to be able to monitor it via an HTTP web interface. I don't need something complicated and I definitely don't want something that's difficult to set up. Previously I've used the Google App engine and the functionality in the Logs tab is completely fine.
The app is served through nginx & gunicorn and uses redis (w/ py-redis) and sqlite (w/ peewee). Ideally I'd like to be able to check the logs for all parts of the system from one place. Is this possible? What's the easiest way?
There is no definitive answer to the predicament and it would be whatever way you are most comfortable with.
You could change all your logging to write to a central database then create a small program which would scrape this data for you. This method also includes configuring a central syslog server:
http://www.linuxjournal.com/content/creating-centralized-syslog-server
What ever way you want to read these files is fine and all depends how much control you want. You could simply name all the logs based on hostname and rsync them to a central server from where you could parse them.
There are also free tools out there which will aid you in choosing you method take a look at:
http://www.linuxjournal.com/content/creating-centralized-syslog-server
There are also some proprietary systems you could use, such as Splunk:
http://www.splunk.com/
This is by no means a definitive list but should aim you in the right direction.

How to write basic webpage in python without using framework? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Could you please tell me, How do I write a basic webpage without using framework like Django, Web2Py and others third party frameworks. Also, I don't like to use CGI for it. I need basic MVC structure with a hello-world web page only.
I suppose you mean a http server, because for a webpage only, you'd use html, not python.
I suggest you start with some reading on this page. It's the http server for python. As you want to keep things easy, you probably just want to overwrite the BaseHTTPRequestHandler or the SimpleHTTPRequestHandler classes, especially the do_GET and do_POST methods.
Note that this won't force you to use MVC, that's your own responsibility. You'll need an actual framework if you want to enforce MVC.

Categories