App directory doesn't show up on google cloud shell - python

Probably a stupid question.
I'm new to google app engine. So I followed the tutorial and successfully deployed their HelloWorld app, where the final steps are done on the cloud shell.
Then I built my own app in flask on my local machine, tested it (pushed the repo to the project's cloud repo) and deployed it from the command line (gcloud app deploy) and it works fine, anyone can use the app on their browser and I can also see the source code in the console website.
But I don't see any directories when I use the cloud shell. I get the prompt username#project-id:~$ but when I ls, there's just one README file and no other directories, therefore I can't use the devapp_sever.py, gcloud app deploy or any other shell function on this project.
But when I choose the hello world project that was created initially, the shell shows an src directory which contains the app's code and I can use the shell and deploy the app from there.
What's happening here and what am I supposed to do.?

Think of your Cloud Shell as just another workstation with local disk similar to your local machine. To deploy code to an app engine app, Google will create a Cloud Source Repository. Having said that, this is not related to your Cloud Shell. You can of course git clone any Git repo into your Cloud Shell.
Dan also wrote a nice explanation here -
https://stackoverflow.com/a/42123320/7947020
Hope this clarifies it!

Related

Can't update website built on Google Cloud Platform

I have set up a Google Cloud website using a simple hello world tutorial in Python. I have then edited my code (just changed Hello world to put out another text), and I want to redeploy\update the changes from the cloud shell bash, but I cant figure out what the command is. I have tried
gcloud deployment-manager deployments update euphoric-graph-242609 \
I get no errors, but nothing happens. And the website still shows Hello World instead of the edited code.
Here are the steps I used to create the website, following the App Engine tutorial steps - starting with
git clone
https://github.com/GoogleCloudPlatform/python-docs-samples
cd python-docs-samples/appengine/standard_python37/hello_world
virtualenv --python python3 ~/envs/hello_world
source ~/envs/hello_world/bin/activate
pip install -r requirements.txt
python main.py
gcloud app create
gcloud app deploy app.yaml --project euphoric-graph-242609
and I just now realised running the last code again would redeploy the app. But is this the correct way of just updating the app? Or should I use some update command like I tried first?
Running gcloud app deploy app.yaml --project euphoric-graph-242609 again would re-deploy any changes.

Where is my python-flask app source stored on ec2 instance deployed with elastic beanstalk?

I just deployed a flask-python app with elastic beanstalk on AWS but cannot locate my app source files like application.py or templates/index.html etc
I've looked at looked at /var/../.. or /opt/../.. etc but nowhere to be found.
Is there an ebs command like $ eb find 'filename.py' etc?
/opt/python – Root of where you application will end up.
/opt/python/current/app – The current application that is hosted in the environment.
/opt/python/on-deck/app – The app is initially put in on-deck and then, after all the deployment is complete, it will be moved to current. If you are getting failures in yourcontainer_commands, check out out the on-deck folder and not the current folder.
/opt/python/current/env – All the env variables that eb will set up for you. If you are trying to reproduce an error, you may first need to source /opt/python/current/env to get things set up as they would be when eb deploy is running.
opt/python/run/venv – The virtual env used by your application; you will also need to run source /opt/python/run/venv/bin/activate if you are trying to reproduce an error
As of today, using the default AWS Linux option when creating eb (Python 3.7 running on 64bit Amazon Linux 2/3.1.1), I found the application files in:
/var/app/current
If that doesn't work you can search for a file that you know to be unique in your app, e.g
sudo find / -name hello.html
In my case the above returns
/var/app/current/templates/hello.html

How to deploy django web application on Microsoft Azure cloud services

I have a existing django web application currently deployed on aws. I want to deploy it on Microsoft Azure by using cloud services. How to create config files for deploying web app on Azure? How to access environment variables on Azure? I am not using Visual Studio. I am developing web app in linux env and using git for code management. Please help
It sounds like you want to know which way is the best choice for deploying a django app via Git for code management on Linux, using Cloud Services or App Services on Azure.
Per my experience, I think deploying a pure web app into App Service on Azure via Git on Linux is the simplest way for you. You can refer to the offical docuemnts below to know how to do it via Azure CLI or only Git.
Deploy your first Python web app to Azure in five minutes
Local Git Deployment to Azure App Service
And there is a code sample of Django on App Service as reference that you can know how to configure it for running on Azure.
However, if your app need more powerful features & performance, using Cloud Services for your django app is also a better way than using VM directly. Also as references, please view the document Python web and worker roles with Python Tools for Visual Studio to know how to let Azure support Python & Django on Cloud Services, and you can create & deploy it via Azure portal in the browser on Linux. Meanwhile, thanks for the third party GitHub sample of Django WebRole for Cloud Service which you can refer to know how to create a cloud service project structure without PTVS for VS on Linux.
Hope it helps.
I read this post, decided the how-to guides Peter Pan posted looked good, and set off on my own. With my one business day's worth of experience if you are looking to deploy your app to Azure, start with the Marketplace Django app and go from there. Reason being the virtual environment comes with it along with the activate script needed to run the virtual environment and the web.config is setup for you. If you follow the start from scratch how-to guides, these are the hardest parts to setup correctly. Once you create the app service from the template, do a git clone of the repo to your local machine. Make a small change and push it back up by running the command below in bash.
az webapp deployment source config-local-git --name <app name> --resource-group <group name> --query url --output tsv
Use the result of the command to add the git repo as a remote source.
git remote add azure https://<ftp_credential>#<app_name>.scm.azurewebsites.net/<app_name>.git
Finally, commit your changes and deploy
git add -A
git commit -m "Test change"
git push azure remote
A couple of side notes
If you do not have your bash environment setup, you'll need to do so to use the az commands. The marketplace app does run error-free locally. I have not dug into this yet.
Good luck!

Deploy webapp on GAE then do changes online from GAE console

I deployed a webapp2 python application on GAE. Is there any way with which i can explore the source code or make changes in the project files from GAE console. Is it possible that if i only want to update a single .py file on already deployed app rather than again deploying the whole project?
I think you're looking for this :
https://console.cloud.google.com/code/develop
I pushed my code on Google Cloud Platform with git, and I'm able to change text files directly online.
The doc is here :
https://cloud.google.com/source-repositories/

How do I use the Python SDK for Google Appengine?

I normally use Java development and the Google Eclipse plugin, which integrates GoogleAppEngine deploy capability.
Now I have found a Python application with source code that I want to bring into Eclipse and deploy from Eclipse, but I don't even know if Eclipse supports Python.
What do I have to do to deploy the Python app to GAE ?
Download PyDev from its Eclipse update site.
Create a new PyDev Google App Engine Project, say using the 'Hello webapp world' template.
Set the application in app.yaml to your GAE application ID.
Right-click the src folder of your project and select Run As | PyDev:Google App Run.
Test the application works as expected in your browser.
Right-click the src folder of your project and select PyDev:Google App Engine | Upload. Follow the prompts.
Check that it works on your GAE site.
Replace the hello webapp world code with your actual application's code and retest locally, then upload again and test.
Take a look at Pydev - http://pydev.org/
I haven't used python via Eclipse at all so I'm not sure how things map to the way Eclipse deploys, but generally to deploy all you need to do is this from the command line:
appcfg.py update <app directory>
You can find more help about using Python with appengine here:
http://code.google.com/appengine/docs/python/gettingstarted/

Categories