I want to be able to give out a form, with essentially 4 inputs. Each time it is submitted, I would it to trigger a python script.
I'm not totally sure where to start here. I could have the python code live on a server somewhere and have the google apps script trigger it, but ideally I could do this without having to host my code somewhere else. I also would like to avoid paying for anything...
Any and all advice would be appreciated. Please assume I have only a small amount of knowledge about this kind of stuff.
Check out this tutorial on the AppEngine documentation.
https://developers.google.com/appengine/docs/python/gettingstartedpython27/introduction
It will help you set up using Python and WebApp2 (for your forms!) and storing this data to datastore if you wish. You could just expand and modify the guestbook tutorial they make you do to have your application/script do exactly what you need it to. It's an excellent tutorial to get started even if you don't have much knowledge about python or appengine.
Related
I want to be able to run my own python script (which will basically just print out the response with a bit of formatting) whenever a new response is submitted to my google form. I looked at google's python API for forms, but it doesn't seem to have a way to set up a trigger so that the script executes when a new response is submitted. Best it can do is pull a response ID after the fact and give me the details of the response. Is there a way to do this? From what I've seen google's apps script can't do what I need it to (print stuff onto paper), so I would prefer to make a trigger for my own python script.
Any help appreciated. If the answer to this question is painfully obvious, please guide me in a good general direction because I'm totally lost.
Thanks!
You have to rethink your "solution" as the Google Forms API doesn't support triggers but Google Apps Script script does, i.e., you might make your Python program to poll the form or the linked spreadsheet.
From https://developers.google.com/forms
Automate Google Forms with simple code
Anyone can use Apps Script to automate and enhance Google Docs in a web-based, low-code environment.
Automate tasks based on Google Form submissions.
I would like to know what is the fastest way to turn a simple Python script into a basic web app.
For example, say I would like to create a web app that takes a keyword from the user and display the most retweeted tweet on Twitter. If I write a python script that is capable of performing that task using Twitter's API, how would I go about turning it into a web app for people to access?
I have looked at frameworks such as Django, but it would take me weeks or months to learn how to use it. I just need something quick and simple. Any such alternatives?
Make a CGI script out of it. You basically get the request information from the webserver via environment variables and you print the desired HTML to stdout. There are helper libraries such as Werkzeug which help with abstracting away the handling of the environment variables by wrapping them in a Request object.
This technique is quite outdated and isn't normally used nowadays as the script has to be run on every request and thus incurs the startup cost all the time.
Nevertheless this may actually be a good solution for you because it is quick and every webserver supports it.
folks.
I'm completely new to Pyhton development and i want to know some basic things.
I need to make a bot that access an API and want it to keep running on a server. I did some search and found Google App Engine + python as the best solution for this. So, i have a code example but its a "desktop" app.
I want it to be running on a server (Google App Engine or something like it), every X minutes and when i access the web adress of it, i would like to see the log on screen (just for monitoring).
Here's the code example (of course i don't need the input things and so. It would be hard coded variables in the application. And i know the "print" method wont work as well):
GitHub Code
Coud you guys help me?
Start here for App Engine intro: https://cloud.google.com/appengine/docs/python/gettingstartedpython27/introduction
Then see GAE Cron docs here to "do something every X minutes": https://cloud.google.com/appengine/docs/python/config/cron
If you have any specific questions / problems once you start porting your app - come back and post them. I glanced over your code quickly and don't think you should run into any issues although don't expect anyone here to do your job for you.
My question is quite simple but I can't figure it out. How can I create buttons in google docs spreadsheet which can be seen when logged in. I want to initialize the script upon logging into the google docs rather than going to load manually. Is there a way to do that? Also I couldn't find the nice tutorial which gives the intermediate knowledge about the google-docs function. All I could find was this simple tutorial. Another question is: Can the python script as provided by google-docs be saved and executed in google-docs itself? If it could, it can provide more functionality than simple google-functions. I am completely newbie to google docs so please bear with me.
You can create some UI elements using Google Apps Script.
https://developers.google.com/apps-script/guide_user_interfaces
Apps Script is javascript-like script that runs SERVER side, in google land. It has access to various services and google document model. But is otherwise restricted from many things that you'd think javascript can do. This is the root of most of its limitations. You can enable a script to load on start-up and hook into related events.
While there is Python and Java API to access Google Docs and their content, there is no way to to create the UI elements outside of Apps Script and the related UI Designer:
http://googleappsdeveloper.blogspot.com/2011/06/building-ui-in-apps-script-just-got.html
I'm just starting out with Python and have practiced so far in the IDLE interface. Now I'd like to configure Python with MAMP so I can start creating really basic webapps — using Python inside HTML, or well, vice-versa. (I'm assuming HTML is allowed in Python, just like PHP? If not, are there any modules/template engines for that?)
What modules do I need to install to run .py from my localhost? Googling a bit, it seems there're various methods — mod_python, FastCGI etc.. which one should I use and how to install it with MAMP Pro 1.8.2?
Many thanks
I think probably the easiest way for you to get started is to work with something like Django. It's a top-to-bottom web development stack which provides you with everything you need to develop and run a backend server. Things can be very simple in that world, no need to mess around with mod_python or FastCGI unless you really have the need.
It's also nice because it conforms to WSGI, which is a Python standard which allows you to plug together unrelated bits of reusable code to add specific functionality to your web app when needed (say for example on-the-fly gzip compression, or OpenID authentication). Once you have outgrown the default Django stack, or want to change something specific you can go down this road if you want.
Those are a few pointers to get you started. You could also look at other alternative frameworks such as TurboGears or paste if you wanted but Django is a great way to get something up and running quickly. Anyway, I'm sure you'll enjoy the experience: WSGI makes it a real joy knocking up web apps with the wealth of Python code you'll find on the web.
[edit: you may find it helpful to browse some of the may Django related questions here on stack-overflow if you run into problems]
You asked whether HTML is allowed within Python, which indicates that you still think too much in PHP terms about it. Contrary to PHP, Python was not designed to create dynamic web-pages. Instead, it was designed as a stand-alone, general-purpose programming language. Therefore you will not be able to put HTML into Python. There are some templating libraries which allow you to go the other way around, somewhat, but that's a completely different issue.
With things like Django or TurboGears or all the other web-frameworks, you essentially set up a small, stand-alone web-server (which comes bundled with the framework so you don't have to do anything), tell the server which function should handle what URL and then write those functions. In the simplest case, each URL you specify has its own function.
That 'handler function' (or 'view function' in Django terminology) receives a request object in which interesting info about the just-received request is contained. It then does whatever processing is required (a DB query for example). Finally, it produces some output, which is returned to the client. A typical way to get the output is to have some data passed to a template where it is rendered together with some HTML.
So, the HTML is separated in a template (in the typical case) and is not in the Python code.
About Python 3: I think you will find that the vast majority of all Python development going on in the world is still with Python 2.*. As others have pointed out here, Python 3 is just coming out, most of the good stuff is not available for it yet, and you shouldn't be bothered about that.
My advise: Grab yourself Python 2.6 and Django 1.1 and dive in. It's fun.
Django is definitely not the easiest way.
check out pylons. http://pylonshq.com/
also check sqlalchemy for sql related stuff. Very cool library.
On the other hand, you can always start with something very simple like mako for templating. http://www.makotemplates.org/