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

Root route i.e. '/' shows Error 404. #3 #5

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__pycache__
__pycache__
.vercel
venv
.idea/
5 changes: 3 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from flask import Flask
from flask import Flask, redirect
from flask_restful import Api, Resource
import scrap

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

class geeksforgeeksAPI(Resource):
def get(self, username):
def get(self, username=""):
return scrap.fetchResponse(username)


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

if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion scrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from bs4 import BeautifulSoup as bs
from flask import request, redirect, jsonify

import requests, json

def fetchResponse(username):
Expand Down Expand Up @@ -97,4 +99,4 @@ def fetchResponse(username):

return response
else:
return {"error" : "Profile Not Found"}
return {"error" : "Profile Not Found"}
3 changes: 2 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"use": "@liudonghua123/now-flask"
}],
"routes": [
{ "src": "(.*)", "dest": "app.py" }
{ "src": "(.*)", "dest": "app.py" },
{ "src": "/", "dest": "https://github.com/arnoob16/GeeksForGeeksAPI/"}
]
}