{"id":25208241,"url":"https://github.com/1010code/heroku-flask-api-example","last_synced_at":"2025-10-25T08:30:56.862Z","repository":{"id":52156182,"uuid":"232982554","full_name":"1010code/heroku-flask-api-example","owner":"1010code","description":"Deploying a Machine Learning Model as a REST API","archived":false,"fork":false,"pushed_at":"2021-05-06T19:51:24.000Z","size":28722,"stargazers_count":0,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-28T05:23:24.027Z","etag":null,"topics":["heroku-flask-api","heroku-github","python-flask-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1010code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-10T06:37:21.000Z","updated_at":"2024-04-28T05:23:24.027Z","dependencies_parsed_at":"2022-08-28T15:41:32.299Z","dependency_job_id":null,"html_url":"https://github.com/1010code/heroku-flask-api-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fheroku-flask-api-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fheroku-flask-api-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fheroku-flask-api-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1010code%2Fheroku-flask-api-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1010code","download_url":"https://codeload.github.com/1010code/heroku-flask-api-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238109516,"owners_count":19417881,"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":["heroku-flask-api","heroku-github","python-flask-api"],"created_at":"2025-02-10T12:19:09.517Z","updated_at":"2025-10-25T08:30:55.779Z","avatar_url":"https://github.com/1010code.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 使用Heroku部署機器學習API\n\n## [Medium 文章](https://medium.com/@andy6804tw/%E4%BD%BF%E7%94%A8heroku%E9%83%A8%E7%BD%B2%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92api-eca61ea711f1)\n\n## 範例程式碼\n這一個repo以手寫數字辨識為例，拿一個先已經訓練好的模型進行Python Flask API的開發與部署到Heroku。以下簡要說明Heroku雲端部署所需要的設定檔。\n\n![](https://miro.medium.com/max/717/0*J8NOFIKZ78AqkMEK.png)\n\n### Procfile 設定檔\nProcfile 這個檔案是要告訴 Heroku 要如何啟動這個 web app，在 Heroku 裡，執行 Python 要使用 Gunicorn 來啟動 web server。所以在 requirements.txt 裡，請記得要輸入 gunicorn。Procfile 檔案，的內容如下。\n\n```\nweb gunicorn run:app\n```\n\n### Aptfile 設定檔\n由於我們的 AI 專案內需要使用 OpenCV 的套件，因此我們需要在Heroku中安裝 OpenCV 相關的套件。因為 Heroku 採 Linux 系統，因此我們要透過 apt 來安裝以下函式庫：\n```\nlibsm6\nlibxrender1\nlibfontconfig1\nlibice6\n```\n\n### 部署專案\n確認以下事情都完成後就可以部署程式囉！記得我們有跟GitHub連動，當你的專案git push後Heroku就會幫你自動部署了。你可以從Activity內看到部署狀態，也能從右上角 More -\u003e View logs 觀看後台Log訊息。或者你也可以從Deploy內手動部署也行。\n\n- Python Flask API程式撰寫 ✅\n- 專案內建立Procfile與Aptfile設定檔 ✅\n- Heroku建立專案 ✅\n- Heroku與GitHub連動 ✅\n- Heroku設定Buildpacks ✅\n\n### 測試API\n- [API測試](https://heroku-flask-api-example.herokuapp.com//mnist)\n- [API文件](https://andy6804tw.github.io/digit-recognizer-project/document/API.html)\n\n![](https://miro.medium.com/max/712/1*hurEGbgSEppF2tTADynIig.png)\n\n## Getting Started\n### Clone Project\nyou can create a new project based on heroku-flask-api-example by doing the following:\n\n```bash\ngit clone https://github.com/1010code/heroku-flask-api-example.git\ncd heroku-flask-api-example\n```\n\n### Installation\nWhen that's done, install the project dependencies.\n```bash\npython install -r requirements.txt\n```\n\n### Running the Project\nAfter completing the installation step, you're ready to start the project.\n\n| script | Description |\n| ------| ------ |\n| start | Serves your app at localhost:5001 |\n\n\n`python run.py` running locally! Your app should now be running on [localhost:5001](http://localhost:5001/).\n\n## Contribute\n### Report Issues and Improvement Suggestions\nFile report at this project's [issue](https://github.com/1010code/heroku-flask-api-example/issues) tracker if you noticed some problem or have improvement suggestions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fheroku-flask-api-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1010code%2Fheroku-flask-api-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1010code%2Fheroku-flask-api-example/lists"}