Forum in maintenance, we will back soon 🙂
Need Help With Deploying API On My Host
Hi Hasan,
I generated an python api code (pasted below) after following your course on creating and selling apis. (Amazing Course, by the way).
I have pushed the code on Github, but when I try to deploy it on my Host, it asks for two files;
- composer.lock
- composer.json
Â
here is my api code;
from flask import Flask, request, jsonify import requests app = Flask(__name__) GOOGLE_SUGGEST_API_URL = "https://suggestqueries.google.com/complete/search" @app.route('/keywords', methods=['GET']) def get_keyword_suggestions(): query = request.args.get('query') if not query: return jsonify({"error": "Query parameter 'query' is required."}), 400 params = { "q": query, "client": "firefox", "hl": "en" # Language preference, you can change it as per requirement } try: response = requests.get(GOOGLE_SUGGEST_API_URL, params=params) suggestions = response.json()[1] return jsonify({"suggestions": suggestions}) except Exception as e: return jsonify({"error": str(e)}), 500 if __name__ == '__main__': app.run(debug=True)
Â
I have chated with chatgpt regard the issue but now luck.
Can you please share what are these files and what should they include. Also, what changes should i make to the attached python code.Â
Â
Thanks,
Â
Subha
Â
@subha-sadiq do you have a requirements.txt file in your repository?
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Thank you!
Where and how are you deploying? you don't need this for a Python API. are you sure you selected the right hosting service?
@admin I am deploying this on my site hosted on hostinger. I am using the Git feature via cpanel.
@subha-sadiq I'm confused. Why is Hostinger asking for a composer file when you're deploying Python? Composer is used for PHP.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
@ssadvisor There seems a problem at hostinger's end, will get in touch with their support team.Â
Thank you