```python
from flask import Flask, request, Response
from ollama_api.models import OllamaApi
from ollama_api.views import OllamaApiView
app = Flask(__name__)
class OllamaApiView(OllamaApiView):
def get(self, request):
url = 'http://localhost:5001' # replace with actual URL of Ollama API server
response = requests.get(url)
if response.status_code == 500:
return Response(f"Error: Failed to communicate with Ollama API, status code 500", mimetype='text/plain', headers={'Content-Type': 'text/plain'})
elif response.ok:
return Response(response.content)
@app.route('/')
def home():
return Response('''
This is a simple Flask app that uses the Ollama API for communication with the Ollama server. The app displays a welcome message and a status bar showing the response from the Ollama server, which indicates whether the request was successful or not. If the request was unsuccessful due to an error in the code, the app will display an error message and a 500 status code.
''', mimetype='text/plain')
Sources:- [
Error "'DataFrame' object has no attribute 'append'"] (
https://stackoverflow.com/questions/75956209/error-dataframe-object-has-no-attribute-append)
- [
/api/embeddings responds with 500 before Ollama is initialized - GitHub] (
https://github.com/ollama/ollama/issues/4124)
- [
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported] (
https://stackoverflow.com/questions/69081410/error-err-require-esm-require-of-es-module-not-supported)
- [
Troubleshooting Ollama with Failed Status Codes] (
https://zappedia.com/ollama-call-failed-with-status-code/)
- [
How to fix "running scripts is disabled on this system"?] (
https://stackoverflow.com/questions/64633727/how-to-fix-running-scripts-is-disabled-on-this-system)
- [
Ollama Call Fix: Resolve Status Code 500 - Empower Student Success] (
https://staging.student.empowerly.com/ollama-call-failed-with-status-code-500-invalid-version-ubuntu)
- [
javascript - Axios POST request fails with error status code 500 ...] (
https://stackoverflow.com/questions/50950011/axios-post-request-fails-with-error-status-code-500-internal-server-error)
- [
Ollama: 500 error on Larger Models · Issue #5892 - GitHub] (
https://github.com/ollama/ollama/issues/5892)
- [
The following untracked working tree files would be overwritten …] (
https://stackoverflow.com/questions/17404316/the-following-untracked-working-tree-files-would-be-overwritten-by-merge-but-i)
- [
500 error calling Ollama API at /api/embeddings #1673 - GitHub] (
https://github.com/FlowiseAI/Flowise/issues/1673)
- [
Error: EBUSY: resource busy or locked, rmdir - Stack Overflow] (
https://stackoverflow.com/questions/55212864/error-ebusy-resource-busy-or-locked-rmdir)
- [
Ollama Call Failed: Fixing Status Code 500 Invalid Version Error] (
https://arlevent.ime.calpoly.edu/ollama-call-failed-with-status-code-500-invalid-version)
- [
Git: cannot checkout branch - error: pathspec '...' did not match …] (
https://stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn)
- [
Troubleshooting Ollama Call Failed with Status Code 500: Invalid ...] (
https://awsfw1-us.corp.databricks.com/ollama-call-failed-with-status-code-500-invalid-version)
- [
Error: unable to verify the first certificate in nodejs] (
https://stackoverflow.com/questions/31673587/error-unable-to-verify-the-first-certificate-in-nodejs)
- [
Ollama Call Failed With Status Code 500: Invalid Version] (
https://dw-test.elc.ucdavis.edu/ollama-call-failed-with-status-code-500-invalid-version)
- [
pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY ...] (
https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi)
- [
How to Fix Ollama API Connection Refused Error: Complete Network ...] (
https://markaicode.com/fix-ollama-api-connection-refused-error-troubleshooting/)
- [
docker-compose run issue 2024: Error: 'ContainerConfig'] (
https://stackoverflow.com/questions/78380867/docker-compose-run-issue-2024-error-containerconfig)
- [
500 Error in Ollama API After LLM Computation Exceeds 2 Minutes] (
https://github.com/ollama/ollama/issues/7526)