Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running mids-documentation locally throws 404 (solved with workaround) #91

Open
matdillen opened this issue Aug 1, 2024 · 4 comments
Open

Comments

@matdillen
Copy link
Contributor

Trying to run https://github.com/DiSSCo/mids-documentation locally on Windows, Mac or Ubuntu throws 404 errors on any page.

This can be fixed by running the command set FLASK_APP=app.routes inside the virtual environment.

I have no idea why or how to fix this in the python codebase itself. A workaround not to type this extra command each time is to bundle all commands in .bat file. For Linux, a corresponding bash script should work as well.

https://github.com/DiSSCo/mids-documentation/blob/9dc8c5b95888f5bd320a7564e9a96f3ec74a7d3d/run.bat

@matdillen matdillen moved this to Done in MIDS Project Aug 1, 2024
@sharifX
Copy link

sharifX commented Aug 2, 2024

would this work on python? I think this is the python equivalent of set.
os.environ['FLASK_APP'] = 'app.routes'

@matdillen
Copy link
Contributor Author

matdillen commented Aug 2, 2024

I expected it should, but I got the 404 again if I added these lines to __init__.py:

import os

from flask import Flask

os.environ['FLASK_APP'] = 'app.routes'

@emhaston emhaston added this to the GitHub Website drafted milestone Sep 19, 2024
@samleeflang
Copy link

Ok interesting, I haven't run into this issue.
Could you give some more background on how you run the app?
Do you use run the main function in your local python env, use Flask command line, or maybe something else?

It should be possible to just run the main function, which will kick off the server and make it available on your localhost.
I changed the deployment server to Waitress, as the Flask server is not meant to run as a production server:
https://flask.palletsprojects.com/en/3.0.x/deploying/
That might have caused this issue if you are trying to run it on your local Flask server.
Running the main function should kick off waitress and deploy the Flask application on the WSGI waitress server.
The app will then be available on localhost:8080

What always should work is run it as a container with docker, although for development this might introduce unnecessary delays.
With docker build . -t mids-terms it will build the container and with docker run -p 8080:8080 mids-terms you deploy it on your local docker.
That is also more or less how we run the container in our infrastructure.
I will add a section on how to run it as a container in the README

@matdillen
Copy link
Contributor Author

I used flask command line (from within the virtual environment), but I also tried some other methods including running the python scripts directly from command line. I only tried to get the local test server to show, so I could try and tweak the mappings and the way they are rendered.

The exact commands are in the batch file I linked in my initial comment, but the additional set command is required for this to work without the 404s, which was not the case when I tried to build Ben's version on origin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

4 participants