Skip to content

Commit

Permalink
Merge pull request #443 from amoghak-ds/patch-1
Browse files Browse the repository at this point in the history
Update app.py
  • Loading branch information
dartpain authored Oct 6, 2023
2 parents 0ecc53f + 48f9997 commit 2b0b382
Showing 1 changed file with 8 additions and 35 deletions.
43 changes: 8 additions & 35 deletions application/app.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,41 @@
import platform


import dotenv
from application.celery import celery
from flask import Flask, request, redirect


from application.core.settings import settings
from application.api.user.routes import user
from application.api.answer.routes import answer
from application.api.internal.routes import internal



# Redirect PosixPath to WindowsPath on Windows

if platform.system() == "Windows":
import pathlib

temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath

# loading the .env file
dotenv.load_dotenv()



app = Flask(__name__)
app.register_blueprint(user)
app.register_blueprint(answer)
app.register_blueprint(internal)
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER = "inputs"
app.config["CELERY_BROKER_URL"] = settings.CELERY_BROKER_URL
app.config["CELERY_RESULT_BACKEND"] = settings.CELERY_RESULT_BACKEND
app.config["MONGO_URI"] = settings.MONGO_URI
app.config.update(
UPLOAD_FOLDER="inputs",
CELERY_BROKER_URL=settings.CELERY_BROKER_URL,
CELERY_RESULT_BACKEND=settings.CELERY_RESULT_BACKEND,
MONGO_URI=settings.MONGO_URI
)
celery.config_from_object("application.celeryconfig")



@app.route("/")
def home():
"""
The frontend source code lives in the /frontend directory of the repository.
"""
if request.remote_addr in ('0.0.0.0', '127.0.0.1', 'localhost', '172.18.0.1'):
# If users locally try to access DocsGPT running in Docker,
# they will be redirected to the Frontend application.
return redirect('http://localhost:5173')
else:
# Handle other cases or render the default page
return 'Welcome to DocsGPT Backend!'

return redirect('http://localhost:5173') if request.remote_addr in ('0.0.0.0', '127.0.0.1', 'localhost', '172.18.0.1') else 'Welcome to DocsGPT Backend!'

Check failure on line 30 in application/app.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

application/app.py:30:121: E501 Line too long (157 > 120 characters)



# handling CORS
@app.after_request
def after_request(response):
response.headers.add("Access-Control-Allow-Origin", "*")
response.headers.add("Access-Control-Allow-Headers", "Content-Type,Authorization")
response.headers.add("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS")
# response.headers.add("Access-Control-Allow-Credentials", "true")
return response


if __name__ == "__main__":
app.run(debug=True, port=7091)

2 comments on commit 2b0b382

@vercel
Copy link

@vercel vercel bot commented on 2b0b382 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-gpt – ./frontend

docs-gpt-git-main-arc53.vercel.app
docs-gpt-brown.vercel.app
docs-gpt-arc53.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2b0b382 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextra-docsgpt – ./docs

nextra-docsgpt-arc53.vercel.app
nextra-docsgpt-git-main-arc53.vercel.app
docs.docsgpt.co.uk
nextra-docsgpt.vercel.app

Please sign in to comment.