-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (24 loc) · 921 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
import os
from bson import ObjectId
from flask import Flask, redirect
from errors import handle_exception
app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY')
app.config["JWT_SECRET_KEY"] = os.environ.get('JWT_SECRET_KEY')
@app.route("/", methods=['GET'])
def homepage():
return redirect("https://github.com/bhargavprajapati949/Movies-Search-API")
# return "This is my homepage"
class JSONEncoder(json.JSONEncoder):
''' extending json-encoder class'''
def default(self, o):
if isinstance(o, ObjectId):
''' Converting ObjectId to string for serialization '''
return str(o)
if isinstance(o, set):
''' Converting set to list for serialization '''
return list(o)
return json.JSONEncoder.default(self, o)
app.json_encoder = JSONEncoder
app.register_error_handler(Exception, handle_exception)