Skip to content

Commit

Permalink
Root route i.e. '/' shows Error 404. arnoob16#3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jwright707 committed Jan 2, 2021
1 parent 3cc0697 commit cd6832b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from flask import Flask
from flask import Flask, request, redirect
from flask_restful import Api, Resource
import scrap

app = Flask(__name__)
api = Api(app)

class geeksforgeeksAPI(Resource):
def get(self, username):
return scrap.fetchResponse(username)
def get(self, username=""):
if request.path == '/':
return redirect("https://github.com/arnoob16/GeeksForGeeksAPI/", code=302)
else:
return scrap.fetchResponse(username)

api.add_resource(geeksforgeeksAPI, "/<string:username>")
api.add_resource(geeksforgeeksAPI, "/", "/<string:username>")

if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)

0 comments on commit cd6832b

Please sign in to comment.