{"id":18074391,"url":"https://github.com/headwinds/forge","last_synced_at":"2025-04-05T18:45:46.564Z","repository":{"id":43048032,"uuid":"191959498","full_name":"headwinds/forge","owner":"headwinds","description":"Flask API built with Blueprints standing on the shoulders of Flaskex","archived":false,"fork":false,"pushed_at":"2022-03-21T22:17:42.000Z","size":1191,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-11T16:21:13.835Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://scout.now.sh","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/headwinds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-14T14:45:27.000Z","updated_at":"2019-08-26T01:04:49.000Z","dependencies_parsed_at":"2022-09-18T12:02:55.088Z","dependency_job_id":null,"html_url":"https://github.com/headwinds/forge","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/headwinds%2Fforge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/headwinds%2Fforge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/headwinds%2Fforge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/headwinds%2Fforge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/headwinds","download_url":"https://codeload.github.com/headwinds/forge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247385631,"owners_count":20930599,"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":[],"created_at":"2024-10-31T10:12:28.448Z","updated_at":"2025-04-05T18:45:46.540Z","avatar_url":"https://github.com/headwinds.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forge a modular Python API with blueprints, csrf protection, and recaptcha\n\nso you want to build a simple Flask based python API with [Flaskex](https://github.com/anfederico/Flaskex) and deploy it with [now](https://zeit.co/now)?\n\nBuilt on top of the Flaskex starter, I added the following:\n* registration with recaptcha \n* verify registration account via [email confirmation](https://realpython.com/handling-email-confirmation-in-flask/)\n* more modular blueprint routes so that you can serve json or html templates\n* a route which performs a database join\n* routes that perform all the REST verbs: GET, POST, PUT, DELETE, PATCH \n* redesigned the landing page flow and added a few new pages\n* offline dev: so that you can code without wifi \n* offline sync: the end user could do work in a native app and sync later\n\n# Getting Started \n\nAfter you have setup your [recaptcha](https://pusher.com/tutorials/google-recaptcha-flask) keys, you can either begin with either the remote or local deployment.\n\n#### Local deployment\n\nThen let's dig into the code base and run it locally. \n\n1. create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) called env\n\n```\npython -m venv tutorial-env \n```\n\n2. install the requirements.\n\n```\n$ source env/bin/activate \n$ python install -r requirements.txt\n```\n\n3. rename .env-sample to .env and edit the local database connection uri to match your local setup\n\n```\nDATABASE_URI = \"postgresql+psycopg2://testuser:testpassword@localhost:5432/postgres\"\n```\n\nIf this fails, you will probably need to [create a test user](https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e) on your postgres DB. \n\n4. run the app \n\n```\n$ python app.py \n```\n\nOpen your browswer to http://localhost:5000\n\n#### Remote deployment\n\nLet's deploy it right away in 3 steps.\n\n1. setup your remote postgreSQL database.\n\nI went with [ElephantSQL](https://www.elephantsql.com/) which has a nice free tier for hobbyists. Once you create your database, find that database from the **list all instances** drop down at the top. On the details screen, you should be able to find your url. \n\n\n2. Add your zeit [secrets](https://zeit.co/docs/v2/deployments/environment-variables-and-secrets) \n\n```\nnow secret add flashex-db-uri 'postgresql+psycopg2://username:password@dbhost:dbport/dbname' \nnow secret add flaskex-secret-key 'flaskex' \n```\n\n3. deploy \n\n```\nnow\n```\n\nOpen your browswer then copy and paste the url it provided to your clipboard. \n\nWSGI Server - Zeit supports Waitress\n\n[Flask \u0026 Waitress](https://medium.com/brillio-data-science/exposing-your-data-science-project-to-the-world-flask-with-a-waitress-8592f0356b27)\n\n# Credit \n\nThis codebase is mainly based on the original [Flaskex sample](https://github.com/anfederico/Flaskex) with inspiration taken from the [now flaskex example](https://zeit.co/examples/flaskex-postgresql) which for me went too far. I decided I didn't want a separate flask app running for each route and thought it easier for someone learning python to concentrate on the single app approach. \n\nI also wanted to this example to work completely offline so that I could tinker with it during my subway commute. \n\n# Other nice flask starter projects\n\n* [flask-restplus-server-example](https://github.com/frol/flask-restplus-server-example)\n* [flask_weather](https://github.com/M0nica/flask_weather)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheadwinds%2Fforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheadwinds%2Fforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheadwinds%2Fforge/lists"}