Deploy Python Desktop Application to Web - python

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.

Related

How to run a server in the cloud

Im creating a server in Python that receives POST requests, process the information in the request using some scripts (sometimes using a database) and send back a answer in JSON format. Im searching for a way to run this server and code in the cloud, in a way that i dont need my PC turned on for it to work, because my connection is very unstable.
There are a lot of web hosting companies out there, you just need to find the one that is right for you.
My personal favorite for python apps is heroku, but there are many out there. AWS is another popular one.
In future when asking questions, try to do more research before hand, and try to be more specific with questions. It would have been useful to know what kind of database you are using, or whether you're using flask or django.

Deploy a Python application to web that interacts with local files

Background: Am comfortable in Python, know nothing about web deployment. I am looking into it as an alternative to compiling into .exe or .app for Win or Mac distributions.
Issue: I have a simple application that uses BeautifulSoup, openpyxl, and PySimplyGUI. It interacts with some local excel-files and creates new ones. I want to be able to, using minimum effort, make it accessible on my own web page or something similar, and make the created excel-files available for browsing/download. I have no idea how to do any of this. I've been looking into Flask and cloud foundry, but it feels like there should be some easy alternative that I'm missing. Ideally I would want a page where someone can log in (given a username and password I supply), which then directs to a page where the user can interact with my application.
Request: Is there a relatively easy way to do this that doesn't involve setting up a lot of stuff in html, etc., and where excel-files can still be interacted with by openpyxl? I ideally would just want some template, where I can "fill in the blanks" for the python method I would want to execute for each button!
Hope this makes sense. Thanks in advance :)
The easiest way to create a web app with a simple interface yet effective which does not require frontend programming is Streamlit. It is primarily used by data scientist to create simple web apps quickly.

How to turn a simple python script to basic webapp?

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.

Web application with python

I have a Python program that takes one input (string) and prints out several lines as an output. I was hoping to get it online, so that the web page only has a text-area and a button. Inserting a string and pressing the button should send the string to python and make the original page print out the output from Python.
Assuming I have only dealt with Python and a little bit of HTML and have very limited knowledge about the web, how might I approach this problem?
For some reason, my first instinct was PHP, but Googling "PHP Python application" didn't really help.
That is, assuming what I want IS a 'web application', right? Not a web server, web page or something else?
How could I get a really simple version (like in the first paragraph) up and running, and where to learn more?
Yes, the term you're looking for is "web application". Specifically, you want to host a Python web application.
Exactly what this means, can vary. There are two main types of application - cgi and wsgi (or stand-alone, which is what most people talk about when they say "web app").
Almost nobody uses cgi nowadays, you're much more likely to come across a site using a web application framework, like Django or Flask.
If you're worried about easily making your page accessible to other people, a good option would be to use something like the free version of Heroku do to something simple like this. They have a guide available here:
https://devcenter.heroku.com/articles/getting-started-with-python#introduction
If you're more technically inclined and you're aware of the dangers of opening up your own machine to the world, you could make a simple Flask application that does this and just run it locally:
from flask import Flask, request
app = Flask(__name__)
#app.route('/')
def main():
return 'You could import render_template at the top, and use that here instead'
#app.route('/do_stuff', methods=['POST'])
def do_stuff():
return 'You posted' + request.form.get('your string')
app.run('127.0.0.1', port=5555, debug=True)
Pick a Python web development framework and follow the getting started tutorial. Main options are Django for a "batteries included" approach or Flask for a minimalistic bottom-up approach.

Google apps python script

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.

Categories

Resources