Getting ImportError: cannot import name 'db' from 'flask_sqlalchemy when using github tutorial - database

I'm really stuck on this. I try to make website form using Flask ant SQLAlchemy using this tutorial:
https://github.com/techwithtim/Flask-Web-App-Tutorial/tree/main/website and getting this error.
First, I thought that there is some typo I have made, but I try to copy all the code and getting the same error. What could cause this error? Some configuration settings maybe? Or this tutorial is with mistake?
Folders and files tree is the same as in github example.

Related

How to solve Django custom app unsolved reference error but code working?

I use PyCharm 2022.3.2 CE and Python 3.11.1
I get a Django application that is underline in red (unsolved reference) so I can't use code completion but the code is working. I guess this is a bug from PyCharm but I can't figure it out to get code completion.
Project structure
I try to import model from listings.models to listings.views
Any help would be much appreciated !
Thank you
Try to import Django app to get code completion

importing Amplify throws error "null is not an object (evaluating 'keys.filter)" in react native app

Any time I import Amplify into my React Native project's App.js file, I get the following error:
TypeError: null is not an object (evaluating 'keys.filter')
Here is how I'm importing it:
I run the project using Expo only. If I comment the import Amplify line out, any other files which use anything related to Amplify cause the same error to occur.
Initially, when I was loading this project for the first time, I had other errors to deal with like first needing to create the aws-exports.js file. I copied this over from an old project (Because this is meant to be a re-do of another project that's already set up). Once I included that file I had to update a few lines in that file because of an improper reference to Linking from expo. Once I fixed that, it throw this error I'm referencing here. Now, even if I delete the aws-exports file it will throw this error as soon as Amplify is imported into the App.js file.
-- Update
I've found where the error is occurring. Some of my code gets executed but the error happens inside of the reactnative.js file when syncing between two memory software.
I've tried to reproduce this error inside a fresh react application by copying the package.js file and then importing Amplify into the App.js file but it doesn't throw this error.
Here is a screenshot of where the error is taking place. I'm still trying to figure out how to pinpoint where in my code this error begins.
According to Expo, you have to follow these steps
it would be best if you imported Amplify
import Amplify from '#aws-amplify/core'
All you need to follow those steps it sees the configuration issue result data is not coming that's why it gives a null value and crashes.
Follow steps below will fix your problem
https://blog.expo.dev/how-to-build-cloud-powered-mobile-apps-with-expo-aws-amplify-2fddc898f9a2
The problem seems to be resolved by changing the slug attribute in the react app.json file. I changed the slug from being a camel case to an all lower case slug.
After this the error has gone away for what seems permanent. I've been able to replicate the error in small sample apps. I don't understand why this causes these errors.

Publishing my React website to GitHub pages just produces a blank page

I'm probably missing something really obvious but I'm not very accustomed to GitHub or React so I'd love some advice.
My GitHub is here:
https://github.com/SarahACollins/PortfolioWebsite
I've tried publishing the website here:
https://sarahacollins.github.io/PortfolioWebsite/
and it just produces a blank page. I've tried several different ways of fixing (changing the homepage, moving the index.html to the front, etc.) but can't figure out what's wrong. Any help would be appreciated.
In the developer console it says:
Uncaught SyntaxError: Cannot use import statement outside a module. Looking at the location of the error shows that it is node.js code.:
import React from 'react';
You need to compile your react source code and create a .js file for the client from it.

React app throwing errors when using 'react-pdf'

I've been having trouble getting react-pdf to work properly in my react app that I created using 'create-react-app'. From various github comments on the react-pdf page, it seems that there's an issue setting up the workerSrc in React applications that were created with 'create-react-app'.
One work around that seemed to solve the issue (temporarily) was to copy the pdf.worker.js file from the node-modules/build/pdfjs-dist/build folder and place it in the public folder of my react app. Then in my index.js file put the following code:
import {pdfjs} from 'react-pdf'
window.PDFJS.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.js'
This worked just fine for a week, until I installed a new module into my application with npm. Now, I'm getting the same error I did in the beginning, and nothing has changed:
index.js:14 Uncaught TypeError: Cannot set property 'workerSrc' of undefined
These were the initial comments that helped me narrow down the error:
https://github.com/facebook/create-react-app/issues/1574#issuecomment-280436498
https://github.com/wojtekmaj/react-pdf/issues/291
but now that it's back I'm kind of at a loss for ideas. Has anyone else experienced this and been able to solve it? Any help would be greatly appreciated!
Based on what I have seen in the docs and in forums, it appears you should be altering the global PDFJS object.
PDFJS.workerSrc, instead of window.workerSrc.
I managed to get this working by loading the worker from CDN.
import { Document, Page, pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc=//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js

Errors in Routes requests

im working in a project using angularjs and laravel, but i have a bug i think in my application, im not sure since it happens sometimes, not always. Basically when i open or run my application are made some requests to some routes, but sometimes give me a 500 error, and than the error that is shown in the preview is:
RuntimeException in ApiServiceProvider.php line 88:
Unable to boot ApiServiceProvider, configure an API domain or prefix.
I searched online this error and didnt find much info related with this error, does someone have a idea what could it be?
Yes I have solved the problem, the thing is that you are missing configurations.
The way to solve it you have to make a copy of .env.example file and rename it to .env
Do not forget to change you database configurations.
The problem was missing domain or prefix. which is in your case is:
API_PREFIX=api
I`m sure that it should solve your problem.
Helpful hint turn on your debugging environment in config/app.php to 'debug' => env('APP_DEBUG', true)
so you can be more specific with error messages.
I had same problem even if API_PREFIX was set in my .env file.
Simple solution that I found after long struggle was to clear cache:
php artisan chache:clear
php artisan config:cache

Resources