Is xlrd supported in Google App Engine? - google-app-engine

I have seen posts in Google Groups and here that mention using xlrd in Google App Engine:
How do you read excel files with xlrd on Appengine
https://groups.google.com/forum/?fromgroups=#!searchin/google-appengine-python/xlrd/google-appengine-python/lMix6vXhvtA/O_ExzkGhsKEJ
but when I try to add it to the app.yaml file, it says "the library xlrd is not supported". Also, in the list of 3rd party libraries I don't see xlrd.
https://developers.google.com/appengine/docs/python/tools/libraries27
But then other people seem to be using it on GAE, so does GAE support it or not? In the past I was able to import numpy successfully. Here is app.yaml. On main.py I have "import xlrd". Thank you very much.
application: uploadsample
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"
- name: xlrd
version: "0.7.3"

You can include any pure python third-party libraries with your app that you want. You don't specify them in app.yaml, that's only for third-party libraries that are included by Google on the servers.
xlrd is not "supported" per se, but it should work.

Related

Gcloud deploy is not deploying a folder

I am servicing a system.
An old App Engine tool was used to deploy, but it is now obsolete and I need to use the gcloud command line.
However, gcloud is ignoring one system folder and deploying all others.
One big reason this must be happening is because they developed this system based on node_modules and didn't build the code before uploading. In short, I need the node_modules folder for the code to execute.
I already disabled .gcloudignore, but there have been no changes.
Source folder structure:
Folder Structure in App Engine:
I ran the --verbosity = info code on my gcloud deploy and it appeared that they were ignoring it:
My app.yaml:
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: jinja2
version: 2.6
- name: lxml
version: 2.3
- name: pycrypto
version: 2.6
handlers:
- url: /static
static_dir: app/static
secure: always
- url: /.*
script: manage.app
secure: always
builtins:
- remote_api: on
By default, flask use a "templates" folder to contain all your template files(any plain-text file, but usually .html or some kind of template language such as jinja2 ) & a "static" folder to contain all your static files(i.e. .js .css and your images).
So ideally you should not use /static folder
you will need to update app.yaml to include handler static_dir: static
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: ssl
version: latest
# [START handlers]
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.app
# [END handlers]
The best way to use is
from flask import Flask
app = Flask(__name__, static_folder='static', static_url_path='')

How to configure GCP App Engine app.yaml for PrivateBin?

I would like to host PrivateBin from a GCP App Engine, but I don't know how to configure the app.yaml file. If somebody has done this before, I would appreciate the help. :)
I have tried two options, but neither of them worked:
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /.*
script: index.php
&
runtime: php55
api_version: 1
handlers:
- url: /(.*.(ico$|jpg$|png$|gif$|htm$|html$|css$|js$|xml$))
static_files: \1
upload: (.*.(ico$|jpg$|png$|gif$|htm$|html$|css$|js$|xml$))
application_readable: true
- url: /(.+)
script: \1
- url: /
script: index.php
How do you intend to store your data?
https://github.com/PrivateBin/PrivateBin/blob/master/INSTALL.md#using-a-database-instead-of-flat-files
Looks like private bin uses the filesystem by default, which wont work on GAE Standard. You could do that in GAE flex, but the directory where you are reading and writing to would need to be a mounted Google Cloud Storage Bucket or something for the data to be persistent (as well as be available to multiple instances) https://cloud.google.com/storage/docs/gcs-fuse
The better route seems to be to configure privatebin to use a SQL db, which would be Google Cloud SQL:
https://cloud.google.com/sql/docs/
https://cloud.google.com/php/getting-started/using-cloud-sql-with-mysql

How to serve source folder on Google App Engine?

The below app.yaml pasted below gives error:
sre_constants.error: cannot refer to open group
application: villagegamedev
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /(.*)
static_files: ./\1
upload: ./\1
My express purpose for this test is to serve the source folder. When I Google this effort, the search only comes up with all the docs that say "App Engine does not serve files directly out of your application's source directory unless configured to do so." So how do I configure it to do so?
handlers:
- url: /
static_dir: static
Then just put all of the files you want to serve in a directory named static.
This link gives a full description.
Basically what you should do is;
Create a project on google cloud platform
Create a directory on your computer with the same name as the
project created above. Create your app.yaml file here.
Paste this code into the app.yaml file
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
Install the google sdk into this folder (browse and select this
folder when prompted during installation).
Create a directory named www in your project folder. Save your static website files here.
Start up the google cloud sdk on your computer and run the following command
gcloud app deploy
7.run gcloud app browse to see your website in your browser.
Hope that helps!

Laravel 4 - Not working on Google App Engine

I'm trying to setup Laravel 4 with google app engine.
Here's the step on how I setup
Download laravel using composer following the docs step.
Create a app.yaml file with this
application: laraveldemo
version: 1
runtime: php
api_version: 1
handlers:
- url: /favicon\.ico static_files: public/favicon.ico upload: public/favicon\.ico
- url: /.* script: public/index.php
and start engine.
And thats what I get, following this http://blog.neoxia.com/laravel-4-on-google-appengine-for-php/
Seriously, I don't know what's the problem, it works fine with MAMP.
This problem is related to the 'native' session driver. You can switch you driver to 'cookie' and your app will run just fine.

GAE dev_appserver "No module named lxml"

It seems lxml is not available for me in dev_appserver. I have test project is import lxml line built with windows python sdk 1.6.6. "No module named lxml". I assume something with installed version of python, but I have Python 2.7.
import webapp2
import lxml
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('Hello world!')
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
===
application: teslxml
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"
- name: lxml
version: latest
==
dev_appserver.py teslxml
Update: This isn't true anymore, lxml is now shipped out of the box.
https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries-27
lxml doesn't come out of the box with Google App Engine, you need to install it.
I kept getting the 'no module named lxml' error, but was unable to install the module separately and I resolved this by telling pip to install with a specific version number, like so;
pip install lxml==[versionnumber]

Resources