Lab Setup and Troubleshooting
Use this guide when you need help opening a starter, running a program, or submitting your work. Each lab page specifies the files to edit and the work to complete.
Start from a download
- Download the starter ZIP and extract it. Open the inner project folder in VS Code, with its Python or HTML files directly visible in Explorer.
- In Source Control, choose Initialize Repository. Stage the starter files with +, enter a commit message, and choose Commit.
- Choose Publish to GitHub, sign in if needed, and use the repository name given in the lab. Publish under your own account and make the repository public.
- Open the repository on GitHub and check that the files arrived.
If Git asks for your name and email, follow course setup. An address starting with github.com/rtealwitter/ is the instructor’s repository, not your copy.
Use an existing repository
For labs that continue an earlier assignment, open that repository instead of initializing a new one. When a download adds setup files, compare it with your existing work and copy only what you need.
To get another local copy, open a new VS Code window and choose Source Control → Clone Repository. Select your repository or paste its address from GitHub’s Code button. Choose a parent folder such as Documents/csci40, then open the cloned project.
Add the backend starter
If you already have a twitter-clone repository, extract the backend starter into a separate folder and compare the files. Copy in missing templates, static files, test_setup.py, and database setup files. Add any missing dependencies to your requirements.txt.
Use the starter’s create_app setup in app.py, keeping the routes you’ve written. Put their definitions inside create_app, before return app, and use with connect(request) as db: for queries. Keep app = create_app() at the end of the file so the server can find the app. Run python -m pytest test_setup.py to check the setup before continuing with your routes.
Run Python and tests
Open a terminal in the project folder. Create and activate its Python environment, then use that environment’s python and python -m pip. If python is unavailable before creating the environment, use the platform-specific command in course setup.
- “No such file” or “can’t open file”: check the terminal’s current folder. It should contain the filename in your command.
- “No module named …”: activate the intended environment and install the lab’s requirements with
python -m pip install -r requirements.txt. - An installed command is missing: activate the environment where you installed the package. Reinstall after changing its source.
- Doctests print nothing: all examples passed. Add
-vto show successful examples. - Doctests fail: compare
ExpectedwithGot. Check the input, return type, whitespace, and whether the function prints instead of returning.
Do not commit .env, virtual environments, __pycache__, coverage output, or build directories.
Run a local server
Start the server from the folder containing the app and its templates/static files. Leave that terminal running while you use the browser. A second command may need a second terminal with the same environment activated.
- The browser cannot connect: check that the server started successfully and that the browser address uses its printed port.
- The port is already in use: stop the old server with Ctrl+C, then start the one you want to use.
- Live replies fail in the Saved Conversations lab: check
GROQ_API_KEYin.envand restart withpython app.py --live. Usepython app.pyto continue in local mode without a key. - A template, image, or stylesheet is missing: compare the requested path and capitalization with the filename. Run the app from the repository root.
Restart a server after editing if it was not started with automatic reloading.
Publish a webpage
On GitHub, open Settings → Pages. Choose Deploy from a branch, your default branch, and /(root). Wait for deployment to finish in Actions, then use Visit site.
For a 404, check that index.html is at the top level of the selected branch. For old content, confirm that you committed and synced the edits and that the latest deployment finished. Reload the page afterward.
Submit your work
Save, stage, and commit the required files, then choose Sync Changes. Check the files on GitHub before submitting.
On Gradescope, choose GitHub, connect your account if needed, and select the repository and branch named in the lab. Gradescope grades that submitted snapshot and awards partial credit for the individual checks in the lab checklist. After a fix, commit, sync, and submit again.
Save a lab branch
When the backend lab asks you to preserve a version before continuing the final project, commit your finished work and run:
git switch -c lab-submission
git push -u origin lab-submissionSubmit that branch. Return to your default branch and bring over the lab work:
git switch main
git merge lab-submissionUse master if that is your default branch’s name. If you started directly on lab-submission and have no default branch yet, create it from the completed lab with git switch -c main. Continue final-project work there and leave the submitted lab branch unchanged.