Skip to content
Sign upLog in
← Back to Community

Cannot GET/

Profile icon
[deleted]

When trying to get a outside script file in the views folder, I keep on getting "cannot GET/". How can I fix this?

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
TomMustBe12
Comments
hotnewtop
Profile icon
Vandesm14

You need to add this after the app.use bodyparser code:

app.use(express.static('views'))

Although, I suggest using a public/ folder for all of your frontend assets. Then, instead of static('views'), do static('public'). Then, you can have all of your views, html files, inside public/views.

public ---views ------html ---css ------css files ---js ------js files
Profile icon
[deleted]

@Vandesm14
I get an error

Profile icon
Vandesm14

@TaylorLiang
Oops. You also need to change your get request to render __dirname + '/public/views/index'

Profile icon
BaroodSystems

UseFLASK APP-$FLASK_APP FLASK_DEBUG-1 python -m flask run