Skip to content

Forum in maintenance, we will back soon 🙂

Need Help With Depl...
 
Notifications
Clear all

Need Help With Deploying API On My Host

7 Posts
3 Users
2 Reactions
9 Views
(@subha-sadiq)
Posts: 7
Active Member Customer
Topic starter
 

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


 

 
Posted : 04/25/2024 6:27 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@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

 
Posted : 04/25/2024 11:57 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

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?

 
Posted : 04/25/2024 4:13 pm
(@subha-sadiq)
Posts: 7
Active Member Customer
Topic starter
 

@ssadvisor Yes, I have one

 
Posted : 04/25/2024 6:18 pm
(@subha-sadiq)
Posts: 7
Active Member Customer
Topic starter
 

@admin I am deploying this on my site hosted on hostinger. I am using the Git feature via cpanel.

 
Posted : 04/25/2024 6:20 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@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

 
Posted : 04/25/2024 10:48 pm
(@subha-sadiq)
Posts: 7
Active Member Customer
Topic starter
 

@ssadvisor There seems a problem at hostinger's end, will get in touch with their support team. 

Thank you

 
Posted : 04/26/2024 3:03 am
Share:
[the_ad_group id="312"]