[英]I can't find a host for my python and django website
I've created a website using Django framework.我使用 Django 框架创建了一个网站。 I have HTML CSS Python and SQL.
我有 HTML CSS Python 和 SQL。 I was able to put python into my index.html thanks to : https://docs.djangoproject.com/en/4.0/ref/templates/language/#variables
由于: https ://docs.djangoproject.com/en/4.0/ref/templates/language/#variables,我能够将 python 放入我的 index.html
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.关于 python,我有一个 script.py 生成数字列表
L = [120, 140.65, etc]
此脚本每 10 分钟更新一次,因为数字更改L = [122.2, 140.85, etc]
然后将此列表导入 MySQL。 So the DB changes every 10 minutes.因此数据库每 10 分钟更改一次。 Finally, a table is generated on my site using index.html and css with the updated numbers every 10 minutes.
最后,使用 index.html 和 css 在我的网站上生成一个表格,每 10 分钟更新一次数字。
My website :我的网站 :
--index.html --index.html
--style.css --style.css
--script.py --script.py
--MySQL database --MySQL数据库
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.问题是,我怎样才能找到一个网站主机,它会自动运行我的 script.py(它将每 10 分钟更新一次我的网站),它将理解 html 中的 python(this:
{% for x in story_list %}
)以及将托管我的数据库。 Thank you for your help!谢谢您的帮助! : Sorry for my bad english
: 对不起,我的英语不好
For hosting you can try Python anywhere or Heroku .对于托管,您可以在任何地方尝试 Python或Heroku 。 For executing your code you will probably need something more than just index.html, ie Flask or Django that you even tagged here.
为了执行您的代码,您可能需要的不仅仅是 index.html,即您甚至在此处标记的Flask或Django 。 There are plenty of ways to start cron/interval jobs, like
apscheduler
or for bigger projects - Celery
.有很多方法可以启动 cron/interval 作业,例如
apscheduler
或更大的项目 - Celery
。
You can host this on AWS using Elastic Beanstalk.您可以使用 Elastic Beanstalk 在 AWS 上托管它。 You will create a primary container to host the web app and then a worker container for your script.
您将创建一个主容器来托管 Web 应用程序,然后为您的脚本创建一个工作容器。 Then you define a
cron.yaml
file to start the script every 10 minutes.然后定义一个
cron.yaml
文件以每 10 分钟启动一次脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.