I've created a website using Django framework. I have HTML CSS Python and SQL. I was able to put python into my index.html thanks to : https://docs.djangoproject.com/en/4.0/ref/templates/language/#variables
Regarding python I have a script.py that generates a list of numbers L = [120, 140.65, etc]
This script updates every 10 minutes because the numbers change L = [122.2, 140.85, etc]
Then this list is imported into MySQL. So the DB changes every 10 minutes.
Finally, a table is generated on my site using index.html and css with the updated numbers every 10 minutes.
My website :
--index.html
--style.css
--script.py
--MySQL database
The problem is, how can I find a website host who will automatically run my script.py (which will update my website every 10 minutes), which will understand python in html (this: {% for x in story_list %}
) and which will host my database. Thank you for your help! : Sorry for my bad english
CodePudding user response:
You can host this on AWS using Elastic Beanstalk. You will create a primary container to host the web app and then a worker container for your script. Then you define a cron.yaml
file to start the script every 10 minutes.
CodePudding user response:
For hosting you can try Python anywhere or Heroku. For executing your code you will probably need something more than just index.html, i.e. Flask or Django that you even tagged here. There are plenty of ways to start cron/interval jobs, like apscheduler
or for bigger projects - Celery
.