Forums

Flask and React Guides?

Hello! I currently have a pretty simple flask application and have installed react. I was wondering if there are any guides for getting the two of them working on pythonanywhere?

Like that? https://help.pythonanywhere.com/pages/Flask

Not quite, that is the setup for getting flask up and running. I already have flask up and running, and I wanting more about getting a react app up and running and working with flask on here vs having a react app off of here and calling to the flask api here.

There is nothing specific to PythonAnywhere between Flask and React. From the PythonAnywhere point of view, all the browser-side js are just static files. See https://help.pythonanywhere.com/pages/StaticFiles

I guess the part I am trying to get sorted is when you run npm start for the react app, how do you get that using http://relia7.pythonanywhere.com/ instead of localhost.

It won't work like that on PythonAnywhere. Development server won't work. You need to build it and deploy as static files.

Are there any FAQs/guides I could be pointed to for setting up flask with react deployed as static files?

Those are two pretty separate things. I would look for a flask guide, and a react guide separately.

I've had success with ejecting react so you can access the config file. I'd like to understand how to not eject react though and still config to be built into the flask app.

This is the best tutorial to get started. https://www.youtube.com/watch?v=YW8VG_U-m48&t=308s