Setting up a sever on Google Cloud with Postgresql database? - python

I've been trying for about two weeks now to set up a server for a completed Django app on the google cloud shell. All of the documentation for gcloud is confusing and sends me to several different pages for one task and it is very hard to keep track of what to do. Sites like digitalocean, which is useful for Django program setup, doesn't work on gcloud. I haven't figured out a way to connect a postgres VM to my program through the cloud shell despite having the server running. I am very lost in setting this up. Could someone please help me set up my Django app? It runs perfectly on localhost but when trying to implement it into the google cloud nothing works.
I've done the django-gcloud tutorial already and set up a simple site just by importing the code from google, which doesn't help because all it does is import a completed app and you just type in "gcloud app deploy" which doesn't explain how to set it up so that you can do that.
My program uses python 3, DjangoRestFramework, and Celery. The database is Postgresql.
My full module list is:
Django-1.11.2 amqp-2.1.4 astroid-1.5.3 billiard-3.5.0.2 celery-4.0.2 djangorestframework-3.6.3 isort-4.2.15 kombu-4.0.2 lazy-object-proxy-1.3.1 mccabe-0.6.1 pep8-1.7.0 psycopg2-2.7.1 pylint-1.7.2 pytz-2017.2 six-1.10.0 vine-1.1.3 wrapt-1.10.10

Related

App works locally but crashes on Heroku because of Databases connection

Stack communities,
I need your help. I’ve just written my first app in Python with the dash libraries. I am now trying to deploy thanks to the Heroku frameworks. It first works but when trying to connect it my database (PostGre), it crashed. I think it’s because my connection btw Heroku/PostGre SQL is not working correctly.
I’ve tried many changes within my code but still don’t understand why my app crash.
When I try to run the app, I get the following error within the heroku log :
Image of the Heroku error within the server log
My code can be found here in my Github repositorie.
As of now, my database consists of a giant CSV master file because I want to keep it simple for now.
Link to the Database (Private): https://s3-eu-west-1.amazonaws.com/iag-test1/Test1.csv
*On Heroku it seems that I should use the AWS-S3 and connect it. But I didn't manage to do it.
The goal of this project is to build an end-to-end visualization tool in python and deploy it. (I decided to use Dash Library and Heroku to deploy it). Maybe I should switch to AWS...
Any help/advice would be greatly appreciated…

Google App Engine Deploy Error When Deploying Python

Currently I am trying to deploy a server for Mit App Inventor, when I browser the project it looks just fine and the local host works as well. The problem is that when I try to deploy it I get an error. I am using python 2.7.8. By the way I am doing this project from my other gmail account.
I have tried and retried a thousand times, but with no result. Can you please help me?
This is the main error
It says that that's an error when reading a line.
From what I can see you're still using the Google App Engine Launcher which I think was deprecated and is no longer supported. The point is that it still uses appcfg.py to deploy and from the error message you get it also tries to use login/password for authentication which is also no longer supported.
Today you should use the Cloud SDK and the gcloud command line to manage/deploy your app. I'm confident that will solve your issue.

How to deploy a bottle webapp in production?

I wrote a little bottle web application, played around with setup.py, and I'm ready to deploy.
I had two questions:
How do I deploy this new web app in production? Do I need a a webserver or reverse proxy? Can my main.py be run as a service? How is this typically done?
My web app uses a mongodb backend. Is there a way to package that with my application or to require it / look for it / alert the user when the installer runs? How is this typically done?
Pythonanywhere allows you for free to test/deploy a Bottle app with Pymongo driver. This is one of the webhostings which is python-deployers friendly... If you need something for a serious trafic, then you have to consider a paid programm or your own (virtual/dedicated) hosted server.
I ran my Bottle applications on OpenShift. There's a quickstart template on GitHub for getting a Bottle application online. You could just copy their directory structure and files, add your own, and send it all to the git repository that is created for you. OpenShift uses git when it comes to development, so if you ever make any changes, you just need to commit and push them to the server again.
MongoDB and RockMongo (a GUI for managing your MongoDB database, similar to phpMyAdmin for MySQL) are built in. You get three 'gears' or instances to work with, so the Bottle application will be one, with MongoDB and RockMongo included. You just have to enable them.

Execute python script in localhost

I have downloaded and installed python on my PC. I am learning python at this moment so I am a beginner.
Is there anyway I could execute python scripts in localhost (Apache) and view them in a web browser as we do with PHP? I am executing the python scripts from CLI at this moment.
Although there are multiple solutions, I would take a look at mod_python. Unfortunately, in my experience it is not the easiest thing in the world to set up and requires making changes to httpd.conf, but this tutorial is helpful (and gives some examples).
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser.
The development tutorial is here
Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.

Debugging server script like python?

I'm new to 'network' programming. I've done throughout the Google app engine tutorial and I'm trying to make my own application which is guestbook. It has a server script on Google app engine and client app is running on iPhone.
But how do I check if the server is received my message from iPhone?
or How do I debug the script I wrote on server side? (it's an python script)
I want to make sure the data is in right format and other stuff.
Please somebody give me a link if there's good tutorial or good place to start. thanks.
In your code you should be using tons of logging calls. In the app engine dashboard for your app there is an option to view logs, and all of your logging calls will show up in there (and can be filtered in various ways).
There are also ways to run dev_appserver.py and debug locally using software like PyDev, but you'd have to make your iPhone app send its messages to the address of your local server.

Categories