Conversation
Fixed code so the server can run and run on port 8000
There was a problem hiding this comment.
Pull request overview
Updates the project to run the Flask app as a proper package/module (instead of cd’ing into forum) and aligns imports accordingly.
Changes:
- Update
run.shto setFLASK_APP=forum.appand run Flask on a specified port. - Convert
forum.*absolute imports to package-relative imports (from .models ...) across key modules.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| run.sh | Switches to module-based Flask startup and changes the run port. |
| forum/routes.py | Updates imports to package-relative form. |
| forum/app.py | Updates model import to package-relative form. |
| forum/init.py | Updates blueprint/db imports to package-relative form. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # you can ALSO or RATHER use the following command to run the app | ||
| cd ./forum; flask run | ||
| export FLASK_APP=forum.app | ||
| flask run --port 8000 |
There was a problem hiding this comment.
run.sh hard-codes the Flask port to 8000, but the README currently documents that ./run.sh serves on port 5000. Consider either switching back to the default/5000 for local dev, or making the script respect $PORT (with a sensible default) so it works consistently across environments.
| flask run --port 8000 | |
| flask run --port "${PORT:-5000}" |
| export SECRET_KEY="kristofer" | ||
| # honcho start | ||
|
|
||
| # you can ALSO or RATHER use the following command to run the app | ||
| cd ./forum; flask run | ||
| export FLASK_APP=forum.app |
There was a problem hiding this comment.
SECRET_KEY is being exported from run.sh with a fixed value. This is a security risk (secret committed/replicated across environments) and also diverges from the config-based setup in config.py. Prefer reading the secret from the environment (or a local uncommitted .env) and failing fast when it’s missing, rather than setting a constant in the script.
| from flask import Blueprint, render_template, request, redirect, url_for | ||
| from forum.models import User, Post, Comment, Subforum, valid_content, valid_title, db, generateLinkPath, error | ||
| from forum.user import username_taken, email_taken, valid_username | ||
| from .models import User, Post, Comment, Subforum, valid_content, valid_title, db, generateLinkPath, error | ||
| from .user import username_taken, email_taken, valid_username |
There was a problem hiding this comment.
There are two from flask import ... imports at the top of this file (line 1 and line 5), which duplicates render_template/request/redirect/url_for. Consolidating these into a single import keeps the module header easier to maintain and avoids accidental divergence.
new updates made by David