Browse Source

resolving issue with 404 not found on internal URLs

joel
Simon Bowie 2 years ago
parent
commit
45df0ff5ac
7 changed files with 25 additions and 25 deletions
  1. +5
    -5
      web/app/auth.py
  2. +4
    -4
      web/app/book.py
  3. +1
    -1
      web/app/create.py
  4. +3
    -3
      web/app/main.py
  5. +4
    -4
      web/app/practice.py
  6. +4
    -4
      web/app/publisher.py
  7. +4
    -4
      web/app/tool.py

+ 5
- 5
web/app/auth.py View File

auth = Blueprint('auth', __name__) auth = Blueprint('auth', __name__)


# routes for login page # routes for login page
@auth.route('/login')
@auth.route('/login/')
def login(): def login():
return render_template('login.html') return render_template('login.html')


@auth.route('/login', methods=['POST'])
@auth.route('/login/', methods=['POST'])
def login_post(): def login_post():
email = request.form.get('email') email = request.form.get('email')
password = request.form.get('password') password = request.form.get('password')
return redirect(url_for('main.profile',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) return redirect(url_for('main.profile',_external=True,_scheme=os.environ.get('SSL_SCHEME')))


# routes for signup page # routes for signup page
@auth.route('/signup')
@auth.route('/signup/')
def signup(): def signup():
return render_template('signup.html') return render_template('signup.html')


@auth.route('/signup', methods=['POST'])
@auth.route('/signup/', methods=['POST'])
def signup_post(): def signup_post():
email = request.form.get('email') email = request.form.get('email')
name = request.form.get('name') name = request.form.get('name')
return redirect(url_for('auth.login',_external=True,_scheme=os.environ.get('SSL_SCHEME'))) return redirect(url_for('auth.login',_external=True,_scheme=os.environ.get('SSL_SCHEME')))


# route for logout function # route for logout function
@auth.route('/logout')
@auth.route('/logout/')
@login_required @login_required
def logout(): def logout():
logout_user() logout_user()

+ 4
- 4
web/app/book.py View File

book = Blueprint('book', __name__) book = Blueprint('book', __name__)


# route for displaying all books in database # route for displaying all books in database
@book.route('/books')
@book.route('/books/')
def get_books(): def get_books():
books = Resource.query.filter_by(type='book') books = Resource.query.filter_by(type='book')
return render_template('resources.html', resources=books, type='book') return render_template('resources.html', resources=books, type='book')


# route for displaying a single book based on the ID in the database # route for displaying a single book based on the ID in the database
@book.route('/books/<int:book_id>')
@book.route('/books/<int:book_id>/')
def show_book(book_id): def show_book(book_id):
book = get_resource(book_id) book = get_resource(book_id)
links = get_linked_resources(book_id) links = get_linked_resources(book_id)
return render_template('resource.html', resource=book, links=links) return render_template('resource.html', resource=book, links=links)


# route for editing a single book based on the ID in the database # route for editing a single book based on the ID in the database
@book.route('/books/<int:book_id>/edit', methods=('GET', 'POST'))
@book.route('/books/<int:book_id>/edit/', methods=('GET', 'POST'))
@login_required @login_required
def edit_book(book_id): def edit_book(book_id):
book = get_resource(book_id) book = get_resource(book_id)
return render_template('edit.html', resource=book) return render_template('edit.html', resource=book)


# route for function to delete a single book from the edit page # route for function to delete a single book from the edit page
@book.route('/books/<int:book_id>/delete', methods=('POST',))
@book.route('/books/<int:book_id>/delete/', methods=('POST',))
@login_required @login_required
def delete_book(book_id): def delete_book(book_id):
delete_resource(book_id) delete_resource(book_id)

+ 1
- 1
web/app/create.py View File

create = Blueprint('create', __name__) create = Blueprint('create', __name__)


# route for creating a new resource # route for creating a new resource
@create.route('/create', methods=('GET', 'POST'))
@create.route('/create/', methods=('GET', 'POST'))
@login_required @login_required
def create_resource(): def create_resource():
if request.method == 'POST': if request.method == 'POST':

+ 3
- 3
web/app/main.py View File

return render_template('index.html', text=text, tools=tools) return render_template('index.html', text=text, tools=tools)


# route for profile page # route for profile page
@main.route('/profile')
@main.route('/profile/')
@login_required @login_required
def profile(): def profile():
return render_template('profile.html', name=current_user.name) return render_template('profile.html', name=current_user.name)


# route for test page # route for test page
@main.route('/test')
@main.route('/test/')
def test(): def test():
return render_template('test.html') return render_template('test.html')


# route for about page # route for about page
@main.route('/about')
@main.route('/about/')
def about(): def about():
with open('content/about.md', 'r') as f: with open('content/about.md', 'r') as f:
text = f.read() text = f.read()

+ 4
- 4
web/app/practice.py View File

practice = Blueprint('practice', __name__) practice = Blueprint('practice', __name__)


# route for displaying all practices in database # route for displaying all practices in database
@practice.route('/practices')
@practice.route('/practices/')
def get_practices(): def get_practices():
practices = Resource.query.filter_by(type='practice') practices = Resource.query.filter_by(type='practice')
return render_template('resources.html', resources=practices, type='practice') return render_template('resources.html', resources=practices, type='practice')


# route for displaying a single practice based on the ID in the database # route for displaying a single practice based on the ID in the database
@practice.route('/practices/<int:practice_id>')
@practice.route('/practices/<int:practice_id>/')
def show_practice(practice_id): def show_practice(practice_id):
practice = get_resource(practice_id) practice = get_resource(practice_id)
links = get_linked_resources(practice_id) links = get_linked_resources(practice_id)
return render_template('resource.html', resource=practice, links=links) return render_template('resource.html', resource=practice, links=links)


# route for editing a single practice based on the ID in the database # route for editing a single practice based on the ID in the database
@practice.route('/practices/<int:practice_id>/edit', methods=('GET', 'POST'))
@practice.route('/practices/<int:practice_id>/edit/', methods=('GET', 'POST'))
@login_required @login_required
def edit_practice(practice_id): def edit_practice(practice_id):
practice = get_resource(practice_id) practice = get_resource(practice_id)
return render_template('edit.html', resource=practice, resource_dropdown=resource_dropdown, links=links) return render_template('edit.html', resource=practice, resource_dropdown=resource_dropdown, links=links)


# route for function to delete a single practice from the edit page # route for function to delete a single practice from the edit page
@practice.route('/practices/<int:practice_id>/delete', methods=('POST',))
@practice.route('/practices/<int:practice_id>/delete/', methods=('POST',))
@login_required @login_required
def delete_practice(practice_id): def delete_practice(practice_id):
delete_resource(practice_id) delete_resource(practice_id)

+ 4
- 4
web/app/publisher.py View File

publisher = Blueprint('publisher', __name__) publisher = Blueprint('publisher', __name__)


# route for displaying all publishers in database # route for displaying all publishers in database
@publisher.route('/publishers')
@publisher.route('/publishers/')
def get_publishers(): def get_publishers():
publishers = Resource.query.filter_by(type='publisher') publishers = Resource.query.filter_by(type='publisher')
return render_template('resources.html', resources=publishers, type='publisher') return render_template('resources.html', resources=publishers, type='publisher')


# route for displaying a single publisher based on the ID in the database # route for displaying a single publisher based on the ID in the database
@publisher.route('/publishers/<int:publisher_id>')
@publisher.route('/publishers/<int:publisher_id>/')
def show_publisher(publisher_id): def show_publisher(publisher_id):
publisher = get_resource(publisher_id) publisher = get_resource(publisher_id)
links = get_linked_resources(publisher_id) links = get_linked_resources(publisher_id)
return render_template('resource.html', resource=publisher, links=links) return render_template('resource.html', resource=publisher, links=links)


# route for editing a single publisher based on the ID in the database # route for editing a single publisher based on the ID in the database
@publisher.route('/publishers/<int:publisher_id>/edit', methods=('GET', 'POST'))
@publisher.route('/publishers/<int:publisher_id>/edit/', methods=('GET', 'POST'))
@login_required @login_required
def edit_publisher(publisher_id): def edit_publisher(publisher_id):
publisher = get_resource(publisher_id) publisher = get_resource(publisher_id)
return render_template('edit.html', resource=publisher) return render_template('edit.html', resource=publisher)


# route for function to delete a single publisher from the edit page # route for function to delete a single publisher from the edit page
@publisher.route('/publishers/<int:publisher_id>/delete', methods=('POST',))
@publisher.route('/publishers/<int:publisher_id>/delete/', methods=('POST',))
@login_required @login_required
def delete_publisher(publisher_id): def delete_publisher(publisher_id):
delete_resource(publisher_id) delete_resource(publisher_id)

+ 4
- 4
web/app/tool.py View File

tool = Blueprint('tool', __name__) tool = Blueprint('tool', __name__)


# route for displaying all tools in database # route for displaying all tools in database
@tool.route('/tools')
@tool.route('/tools/')
def get_tools(): def get_tools():
tools = Resource.query.filter_by(type='tool') tools = Resource.query.filter_by(type='tool')
return render_template('resources.html', resources=tools, type='tool') return render_template('resources.html', resources=tools, type='tool')


# route for displaying a single tool based on the ID in the database # route for displaying a single tool based on the ID in the database
@tool.route('/tools/<int:tool_id>')
@tool.route('/tools/<int:tool_id>/')
def show_tool(tool_id): def show_tool(tool_id):
tool = get_resource(tool_id) tool = get_resource(tool_id)
links = get_linked_resources(tool_id) links = get_linked_resources(tool_id)
return render_template('resource.html', resource=tool, links=links) return render_template('resource.html', resource=tool, links=links)


# route for editing a single tool based on the ID in the database # route for editing a single tool based on the ID in the database
@tool.route('/tools/<int:tool_id>/edit', methods=('GET', 'POST'))
@tool.route('/tools/<int:tool_id>/edit/', methods=('GET', 'POST'))
@login_required @login_required
def edit_tool(tool_id): def edit_tool(tool_id):
tool = get_resource(tool_id) tool = get_resource(tool_id)
return render_template('edit.html', resource=tool, resource_dropdown=resource_dropdown, links=links) return render_template('edit.html', resource=tool, resource_dropdown=resource_dropdown, links=links)


# route for function to delete a single tool from the edit page # route for function to delete a single tool from the edit page
@tool.route('/tools/<int:tool_id>/delete', methods=('POST',))
@tool.route('/tools/<int:tool_id>/delete/', methods=('POST',))
@login_required @login_required
def delete_tool(tool_id): def delete_tool(tool_id):
delete_resource(tool_id) delete_resource(tool_id)

Loading…
Cancel
Save