{"id":18522456,"url":"https://github.com/pdrastil/demo-python-flask","last_synced_at":"2026-05-02T05:03:28.154Z","repository":{"id":53621159,"uuid":"236227386","full_name":"pdrastil/demo-python-flask","owner":"pdrastil","description":"Flask demo application","archived":false,"fork":false,"pushed_at":"2023-05-01T21:19:37.000Z","size":13,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T18:11:22.430Z","etag":null,"topics":["flask","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pdrastil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-25T20:44:11.000Z","updated_at":"2021-03-20T11:37:41.000Z","dependencies_parsed_at":"2024-11-06T17:38:44.156Z","dependency_job_id":"236d3c2a-9b90-4e2c-8dd9-35d5cf1d5e97","html_url":"https://github.com/pdrastil/demo-python-flask","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pdrastil/demo-python-flask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-python-flask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-python-flask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-python-flask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-python-flask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pdrastil","download_url":"https://codeload.github.com/pdrastil/demo-python-flask/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pdrastil%2Fdemo-python-flask/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261237812,"owners_count":23128843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","python"],"created_at":"2024-11-06T17:31:10.364Z","updated_at":"2026-05-02T05:03:28.050Z","avatar_url":"https://github.com/pdrastil.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask demo application \nA Flask demo application that outputs current date, time, IP address and CPU load.\n\n## Dependencies\nTo host the application install following packages\n\n```sh\n$ sudo apt-get -y update\n$ sudo apt-get -y install python3 python3-venv python3-dev\n$ sudo apt-get -y install git nginx\n```\n\n## Deployment\nTo deploy this application to your server run following commands:\n\n```sh\n$ git clone https://github.com/pdrastil/flask-demo\n$ cd flask-demo\n$ python3 -m venv venv\n$ source venv/bin/activate\n(venv) $ pip3 install -r requirements.txt\n```\n\n## Production web server\nWhen you run the server with `flask run`, you are using a web server that comes with Flask.\nThis server is very useful during development, but it isn't good choise for a production use.\nInstead of a Flask developent server I've decided to go with `gunicorn`, which is also a pure\nPython web server, but unlike Flask's, it is a robust production server that is used by a lot\nof people, while at the same time it's very easy to use.\n\nTo start web application under gunicorn you can use following command:\n```sh\n(venv) $ pip3 install gunicorn\n(venv) $ gunicorn -b localhost:8080 -w 4 app:app\n```\n\nThe `-b` option tells gunicorn where to listen for requests, which I set to internal network\ninterface at port 8080. It is usually a good idea to run Python web applications without\nexternal access, and then have a very fast web server such as `nginx` that is optimized to serve\nstatic files accepting all requests from clients. This fast web server will serve static files\ndirectly, and forward any requests intended for the application to the internal server.\n\nThe `-w` option configures how many *workers* gunicorn will run. Having four workers allows the\napplication to handle up to four clients concurrently, which for a web application is usually\nenough to handle a decent amount of clients, since not all of them are constantnly requesting content.\n\nThe `app:app` argument tells gunicorn how to laod the application instance. The name before\nthe colon is the module name, and the name after the colon is the entrypoint to of the application.\n\n## Process supervisor\nWhile setup is very simple, running the server from the command-line is actually not a good solution\nfor production. What we want is to have server running in background, and have it under constant monitoring,\nbecause if for any reason server crashes and exits, we want to make sure new server is automatically started\nin its place. Also we want to make sure that if machine is rebooted, the server will automatically start upon\nboot. We are going to use `supervisor` package to do this.\n\n```sh\n$ pip3 install supervisor\n```\n\nThe supervisor utility uses configuration files that tell it what programs to monitor and how to restart them when\nnecassary. Configuration files must be stored in `/etc/supervisor/conf.d`. Here is example configuration for this\nweb application.\n\n```conf\n[program:flask-demo]\ncommand=/home/ubuntu/flask-demo/venv/bin/gunicorn -b localhost:8080 -w 4 app:app\ndirectory=/home/ubuntu/flask-demo\nuser=ubuntu\nautostart=true\nautorestart=true\nstopasgroup=true\nkillasgroup=true\n```\n\nAfter creation of configuration just reload supervisor to import new service\n\n```sh\n$ sudo supervisorctl reload\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdrastil%2Fdemo-python-flask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpdrastil%2Fdemo-python-flask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpdrastil%2Fdemo-python-flask/lists"}