File size: 1,002 Bytes
6b0a772 | 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 34 | from flask import Flask, request, jsonify
import os
import logging
app = Flask(__name__)
logging.basicConfig(level=logging.DEBUG)
@app.route('/health', methods=['GET'])
def health():
return jsonify({"status": "ok", "service": "freeapis-proxy"})
@app.route('/v1/chat/completions', methods=['POST'])
def chat_completions():
# Placeholder for actual g4f/freeapis integration
return jsonify({
"id": "chatcmpl-freeapis",
"object": "chat.completion",
"created": 1234567890,
"model": "gpt-3.5-turbo",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "This is a response from the Free APIs Proxy (Placeholder)."
},
"finish_reason": "stop"
}]
})
if __name__ == '__main__':
# Ignore 'PORT' env var to avoid conflict with HF Space default (7860)
port = int(os.environ.get("FREEAPIS_PORT", 5001))
app.run(host='0.0.0.0', port=port)
|