Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
Home page redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
rstular committed Sep 19, 2018
1 parent d5286bc commit c127318
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion app/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def About():

Unauthorized = {"error": True, "status_code": 401, "message": "Unauthorized"}
BadRequest = {"error": True, "status_code": 400, "message": "Bad request"}
RootPage = "<center><h3>API Documentation: <a href=\"https://rstular.github.io/projects/lopolis.html\">https://rstular.github.io/projects/lopolis.html</a></h3></center>"

def OtherError(status_code):
return {"error": True, "status_code": status_code}
Expand Down
16 changes: 8 additions & 8 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import os

from flask import Flask, request
from flask import Flask, redirect, request
from user_agents import parse

import api_lib
from functions import About, BadRequest, RootPage
from functions import About, BadRequest
from helpers import *

app = Flask(__name__)
Expand Down Expand Up @@ -106,7 +106,12 @@ def version():

@app.route("/", methods=["GET"])
def root():
return RootPage, 200
return redirect(About()["documentation"], code=302)

@app.errorhandler(404)
def handler(e):
return json.dumps({"error": True, "status_code": 404, "message": "Not found"}), 404


@app.route("/coffeepot", methods=["GET"])
def getcoffee():
Expand Down Expand Up @@ -149,7 +154,6 @@ def brewcoffee():
else:
return json.dumps(BadRequest), 400


@app.route("/coffeepot", methods=["WHEN"])
def whencoffee():
if app.coffee_state == 1:
Expand All @@ -161,7 +165,3 @@ def whencoffee():
@app.route("/teapot")
def teapot():
return json.dumps(ImATeapot), 418

@app.errorhandler(404)
def handler(e):
return json.dumps({"error": True, "status_code": 404, "message": "Not found"}), 404

0 comments on commit c127318

Please sign in to comment.