Intro to Backend Development
  • Introduction
  • SP25 Syllabus
  • Apply to Take the Course
  • Getting Started
  • Weekly Feedback Form
  • Ed Discussion
  • Intro to Backend SP25 Google Calendar
  • Cheat Sheets
    • Assignment Requirements
    • Assignment FAQs
    • Error FAQs 😢
    • Concept FAQs
    • Postman
    • Command Line
    • Virtual Environment
  • Chapters
    • 1. Routes
      • Pre-Class TODO's
      • Lecture
      • Assignment Handout
      • API Specification
    • 2. Databases
      • Pre-Class TODO's
      • Lecture
      • Demo
      • Assignment Handout
      • API Specification
    • 3. Relational Databases
      • Pre-Class TODO's
      • Lecture
      • Demo
      • Assignment Handout
      • API Specification
    • 4. Abstractions
      • Pre-Class TODO's
      • Lecture
      • Demo
      • Assignment Handout
      • API Specification
    • 5. Containerization
      • Pre-Class TODO's
      • Docker Installation
      • Lecture
      • Demo
      • Assignment Handout
    • 6. Deployment
      • Lecture
      • Demo
      • Assignment Handout
    • 7. Images
      • Demo
      • Assignment Handout
    • 8. Authentication
      • Lecture
      • Demo
      • Assignment Handout
    • (Work in Progress) OAuth
      • Pre-Class TODO's
      • Lecture
      • Demo
      • OAuth 2.0 vs OpenID
      • Flask / OpenID example
  • Additional Topics
    • Git and Github
    • HackOurCampus
  • Other AppDev Courses
    • Intro to iOS Development
    • Intro to Android Development
    • Intro to Digital Product Design
  • Deprecated
    • Previous Semester Syllabi
      • FA22 Syllabus
      • SP22 Syllabus
      • FA21 Syllabus
      • SP21 Syllabus
      • FA20 Syllabus
      • SP20 Syllabus
    • Deployment Pre-Class TODO's
    • PA6 Assignment Handout
    • Deployment Demo
    • Final Project (Spring 2019)
      • Final Project Award Winners
Powered by GitBook
On this page

Was this helpful?

  1. Cheat Sheets

Error FAQs 😢

Contributors: Alanna Zhou

PreviousAssignment FAQsNextConcept FAQs

Last updated 2 months ago

Was this helpful?

  • No such file or directory: requirements.txt?

    • Check that you are currently where requirements.txt exists. You'll know this is the case if enter ls (MacOS) or dir (Windows) into your terminal and you don't see requirements.txt or if you didn't spell it right in your command.

    • Or, you may be trying to do pip3 install -r requirements.txt inside of a correctly created and activated venv, but your venv is nested within a path that contains a folder that has a space in the name. Here's a good that explains the issue.

  • No module named 'flask_sqlalchemy'?

    • Make sure you've run pip3 install -r requirements.txt in your activated virtual environment, check out the Virtual Environment page if you need more help!

  • ImportError: cannot import name 'Feature' from 'setuptools'?

    • Make sure that you have an updated Markupsafe version in your requirements.txt that you used to create virtual env: MarkupSafe==1.1.1

  • How to fix "KeyError: 'data'" from running test suite?

    • This means that your backend didn't respond with a format like:{ "success": True, "data": blah } so try making sure that your endpoints match the API spec linked in the backend course.

  • Postman keeps giving me an error?

    • Make sure you are hitting the correct URL in Postman. A correct URL looks like this: http://localhost:5000/api/posts/{id}/comments/, while some examples of incorrect ones look like this: http://localhost:5000/api/posts/{id}/comments, http://localhost:5000/posts/{id}/comments/

    • If you are making a POST request, make sure that you are submitting a JSON request. Body > Raw > JSON

  • Postman 404 Not Found?

    • Is your server running right now? Try checking your terminal. The server may stop when you make changes in your code has errors.

    • Also make sure that you have if name == "main": app.run(host="0.0.0.0", port=5000, debug=True) at the bottom of your app.py.

  • TypeError: list indices must be integers or slices, not str?

    • You may be returning a list, and accessing string values of that list (could be yourself or the testing script), instead of accessing string values of a dictionary. Make sure your responses abide by the API spec which indicates list/dictionary return types.

  • JSONDecodeError?!

    • JSONDecodeErrors are among the most common in this course. It's caused when the testing script tries to parse the JSON data associated with a response (variable res) that does not have any JSON data associated with it. This occurs when your code in app.py encounters an uncaught exception and crashes before your crafted responses can be returned. To debug a JSONDecodeError, you need to look at which request is breaking on res.json() and look deeper into that route method in app.py. We then recommend using Postman to test that specific route.

    • Double check that you are using double quotes " when creating a POST body request.

    • Instead of accessing key values of a dictionary like dict["key"], it's better to use dict.get("key") so that even if the POST request body doesn't contain the key, your code won't throw an error.

  • Test file's base_path = f"{LOCAL_URL}/api/user" has SyntaxError?

    • Our testing script uses what's called an f string. This is only supported by Python 3.6 or higher, so make sure you're running python3 test.py.

  • Table X has no column named Y?

    • Try using sqlite3 to help you debug in the terminal by

      1) opening sqlite3 shell: sqlite3

      2) loading your database file that you generate in your python code, which should show up in the same place as app.py: .open <YOUR FILENAME HERE>.db

      3) seeing all the tables in your database file .tables

      4) show what your table is made of (what the columns are): PRAGMA table_info(<YOUR TABLE NAME HERE>);

Stack Overflow post