{"id":16284787,"url":"https://github.com/pauleveritt/flask-tutorial-extended","last_synced_at":"2025-04-09T00:06:19.511Z","repository":{"id":238125557,"uuid":"795917589","full_name":"pauleveritt/flask-tutorial-extended","owner":"pauleveritt","description":"A Flask version of django-tutorial-extended","archived":false,"fork":false,"pushed_at":"2024-05-12T20:33:15.000Z","size":518,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T22:52:36.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pauleveritt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-04T11:51:04.000Z","updated_at":"2025-01-08T16:55:42.000Z","dependencies_parsed_at":"2024-11-05T11:05:14.111Z","dependency_job_id":null,"html_url":"https://github.com/pauleveritt/flask-tutorial-extended","commit_stats":null,"previous_names":["pauleveritt/flask-tutorial-extended"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauleveritt%2Fflask-tutorial-extended","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauleveritt%2Fflask-tutorial-extended/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauleveritt%2Fflask-tutorial-extended/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauleveritt%2Fflask-tutorial-extended/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauleveritt","download_url":"https://codeload.github.com/pauleveritt/flask-tutorial-extended/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947860,"owners_count":21023066,"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-10T19:20:58.899Z","updated_at":"2025-04-09T00:06:19.496Z","avatar_url":"https://github.com/pauleveritt.png","language":"CSS","readme":"# Flask Tutorial Extended\n\nA Flask implementation of the official Django tutorial, extended for PyCharm demo uses.\n\n## Prerequisites\n\n- Python 3.10+\n- NodeJS\n\n## Installation\n\n- Clone this repo and go to the directory.\n- `python -m venv .venv`\n- `.venv/bin/pip install --upgrade pip`\n- `.venv/bin/pip install -r requirements.txt`\n- `npm install`\n- `npm build`\n- `npm css`\n- Generate the seed data with `$ flask --app polls.main seed`\n  - To reset the data: delete the instance/database.db file and re-run\n- Open PyCharm Professional\n- Enable Prettier and Black support to run on save\n- Settings | Languages \u0026 Frameworks | Node.js and check `Coding assistance...`\n- Mark directories\n    * `dist` as Excluded\n    * `tests` as Test\n    * `polls/templates` as Templates\n    * `polls/static` as Static resources\n- Settings | Languages \u0026 Frameworks | Template Languages, enable `Jinja2`\n- Make a Flask run configuration\n    - `Application file` as `polls/app.py`\n    - `Uvicorn options` as `--reload --port 8080`\n- Visit `http://127.0.0.1:8080/` and click `Questions` for the server HTML\n- Go to `package.json` and run the `dev` script for the React frontend\n    - Then click the URL in the run output\n- Double-click on `database.db` to connect to SQLite\n    - Install the drivers if needed\n\n*Important note: Some features expect the database to have the seed content. Before demos, stop the server and\ndelete `database.db`, then restart.*\n\n## Main Demo\n\nWe're going to talk about the \"I\" in \"IDE\".\n\n### Project Setup\n\n- PyCharm eliminates some cumbersome setup steps\n- Show that you could use PyCharm's bundled `Flask` template in `New Project`\n    - Makes and sets a virtual env\n    - Installs Flask into it\n    - Makes a sample Flask project\n    - Creates run configuration\n\n### Running/Debugging Flask Server\n\n- Shift-Shift `tem/bas` to open `templates/base.html`\n- Run the `Flask Server` run configuration\n- Click on link in the run window\n- Navigate to `Questions`\n    - Delete the `img` with `PyCharm.svg`\n    - Save\n    - Reload browser\n    - See that Flask restarts the process\n- Run server under the debugger, not a big speed hit\n    - Stop the running server\n    - Restart it with the debugger\n    - Set breakpoint in:\n        - `polls.router.read_questions_html`\n        - Also in `templates/questions.html`\n            - Inside `{% for question in questions %}`\n    - Reload the page at `/question/`\n    - Show stepping through Python and Jinja2\n    - Clear the breakpoints and resume\n\n## Database\n\n- Double-click on `database.db`\n- Browse to `question` table\n- Double-click to open it\n- Normal DataGrip demo stuff\n\n## Endpoints\n\n- Make sure Flask server is running\n- Open endpoints tool and show the discovered endpoints\n    - Click fourth endpoint `/v1/question/ GET`\n        - Run the HTTP Client to test it\n- Shift-Shift question_id and click the `Endpoints` tab\n- Open `static/site.js` and show autocomplete of URL\n\n## SPA Frontend\n\n- Go to `package.json` and run `start` script\n- Click the link\n- Option-Cmd-O to Navigate to Symbol `App`\n- Remove the import of `Index`\n- Autocomplete the usage and show the import, then navigate to it\n- Go to `className` and start adding `ca-a`\n- Hover over the second choice (the Tailwind one) to preview the Tailwind class\n- Escape to not add it\n- Right-click on `src` and choose `Run tests` to see Vitest testing\n- Double-click the first test to open\n- Change `3` to `2`\n- Click gutter icon to run just that test\n- Mouse-over the `.length` assertion to see inlay with error info\n- Set a breakpoint on that line\n- Run test under the debugger\n\n## pytest\n\n- Right-click on `tests` directory and choose `Run`\n- Double-click on `test_read_questions_json` and set a breakpoint on `data =` line\n- Click gutter icon to debug that one test\n- Remove breakpoint\n- Click continue\n- Open `polls.router.read_questions`\n- Set a breakpoint on `questions =`\n- Re-run test under debugger\n- Step over and see what is returned\n\n## HTTP Files\n\n- With server running NOT in debug\n- Open `run-apis.http`\n- Click the `\u003e\u003e` green arrows at top to run all the tests\n- Open `polls.router.read_questions`\n- Set a breakpoint on `questions =`\n- Stop the server and run it under the debugger\n- Click the `\u003e\u003e` green arrows\n- Execution stops on that route\n\n## External Tools (Prettier, Black)\n\n- Show the settings/preferences that configure both\n- Make a change in some Python and save, showing that it reformats\n- Same in `App.jsx`\n\n## Docker\n\n- Normal Dockerfile stuff","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauleveritt%2Fflask-tutorial-extended","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauleveritt%2Fflask-tutorial-extended","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauleveritt%2Fflask-tutorial-extended/lists"}