0

I have some Python code that I want to use in a flutter app. The code imports quite a few python packages. It is designed to take an input from a flutter app, then process it - partly with the help of the packages - then send the output back. I had a look at the various Google Cloud products, and correct me if I'm wrong, but Cloud functions cannot be used with imported python packages, so that rules it out. So I'm left with App Engine and Cloud Run (?). In that case, which of the two should I use to host the backend code, and how can I get started in doing so? Thanks in advance and cheers.

LuckyStrike
  • 69
  • 1
  • 10
  • Do you have severals API endpoints that you want to serve? – guillaume blaquiere May 29 '20 at 07:46
  • No, I guess just one. Dumb question, but if the function returns data back to the app, is it considered an endpoint? If not, then just one. – LuckyStrike May 29 '20 at 07:55
  • 1
    My concern is the following: Cloud Function are designed for "single purpose". App Engine and Cloud Run are webserver oriented, and thus can serve several endpoints with one deployment. By Endpoint, I mean URL (/customer, /cart, /stock,...) – guillaume blaquiere May 29 '20 at 08:31

1 Answers1

0

You can use Cloud Functions with Python, it is a very popular option.

The guide on how to do it is described in this quickstart.

The code should be put in the main.py part and the importst that you used have to be described in a requirements.txt file. Which you can get from you environment, from answer.

Juancki
  • 1,793
  • 1
  • 14
  • 21
  • Can you clarify on how I should put the imports in the requirements.txt? Say I'm using the time package as an import. How should I go about importing mktime? Can I just input the time package in the txt, then use a from.....import..... statement in my main code? – LuckyStrike May 29 '20 at 20:26