Python Forum
Refactored web app with flasks blueprint - 404 error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Refactored web app with flasks blueprint - 404 error
#1
New user to python and Flask here... I have a very basic web app (more of just a shell for a web app that I just started) being hosted in Heroku. I refactored it using Flasks blue print model and now It doesn't hit any of my routes.. I just get a 404 error. Since this question has to do with refactoring the structure of an app it might be best just to look at the repo: https://github.com/jolsendev/PhictitiousBand The branch the changes are on are called BluePrintTestBranch.. I have been over the docs a half a dozen times and it all looks right to me. Any help would be appreciated.
Reply
#2
Man I was hoping to get this done today.. I can't for the life of me see what I did wrong..

Looking at the url_map i found my problem:
Map([<Rule '/api/merchandise' (OPTIONS, GET, HEAD) -> site.merchandise>,
<Rule '/api/tour_dates' (OPTIONS, GET, HEAD) -> site.tour_dates>,
<Rule '/api/setlists' (OPTIONS, GET, HEAD) -> site.setlists>,
<Rule '/api/login' (OPTIONS, GET, HEAD) -> site.login>,
<Rule '/api/forum' (OPTIONS, GET, HEAD) -> site.forum>,
<Rule '/api/media' (OPTIONS, GET, HEAD) -> site.media>,
<Rule '/api/about' (OPTIONS, GET, HEAD) -> site.about>,
<Rule '/stuff' (OPTIONS, GET, HEAD) -> api.stuff>,
<Rule '/api/' (OPTIONS, GET, HEAD) -> site.index>,
<Rule '/api/static/<filename>' (OPTIONS, GET, HEAD) -> site.static>,
<Rule '/static/<filename>' (OPTIONS, GET, HEAD) -> static>])

I has my variable names switched... Don't mind me Ill just be over here questioning my existence..

from flask import Flask
from PhictitiousBand.api.routes import mod as site_mod
from PhictitiousBand.site.routes import mod as api_mod

app = Flask(__name__)

app.register_blueprint(site_mod)
app.register_blueprint(api_mod, url_prefix="/api")
print(app.url_map)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Uninitialized ASN.1 value in Flask LDAP3 Auth blueprint zoidberg 1 4,113 Nov-15-2017, 12:29 PM
Last Post: zoidberg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020