Can i run a gwt project without using a webserver - python

Im making a webserver from scratch in python by simply supplying HTML content through a tcp socket. I want to be able to run gwt projects, is this possible by just echoing the contents of the generated index.html to a browser?

If it is a client-side GWT application, then yes, you could serve it with a basic HTTP webserver that receives HTTP GET requests from a browser and serves files like HTML, JavaScript, images, etc.
If the GWT application includes server-side servlets then it wouldn't work when the client sent requests to the server part of the application.

Related

Connecting a python backend and vue.js frontend on Google App Engine

I have an assignment, building a system on google app engine with python backend(not flask), and Vue.js front end.
The system needs to load the vue.js app(some basic hello world app), on google app engine(google cloud SDK).
I've built the python & yaml side and loaded it to GAE and also built the vue.js side..
but i'm stuck a long time on how can i connect the parts so the python/yaml will load my app on loading the url..
Please Help,
Thanks ahead either way! :)
Strictly speaking, your Python will not directly "load your app".
First, at the risk of unneeded explaining, there's the important concept of where code resides vs where code executes. Your VueJS code resides on the server in a static file but executes in the client / browser.
Q: How does it get from the server to the browser to execute?
A: The client must send a request to the server to provide it.
Q: What would cause the browser to send this request?
A: Instructions in other code sent to it, most probably a <script> tag in HTML.
So, the flow goes something like this (may vary for you depending on details not provided):
Browser sends request to server (GAE) for HTML, such as the home page
Server (GAE) responds with HTML
This HTML may be dynamically created by Python or may be a static file.
This HTML contains tags to instruct the browser to request more files: images, CSS, JS.
This HTML should contain a <script> tag to request your VueJS code.
Browser receives the HTML and processes it, including the <script> tag for your VueJS code.
Browser sends request to server for the VueJS code.
Server (GAE) responds with the static file containing the VueJS code.
Browser receives the file containing VueJS codes, runs it, and your VueJS is now loaded & running!
As your VueJS runs, it may send AJAX requests to the server (GAE) to get data and/or more code.
Your VueJS code must reside in a static file on the server. To the server (Python), this static file is just a meaningless bag-of-bytes (if there's a syntax error in the code it won't be found until it executes client-side).
How do you get these statics files into GAE so they are available when the browser requests it? You probably already got this (for CSS, images), but just in case you don't, see this link: Server Static Files for details on setting this up.

Read files from User end

Hi all thanks for help (in advance)
I developed an HTML form, which takes source and destination from the user and uses python in background to combine those files. I hosted this in my web server but if a user is entering the path which is in his desktop my application is not reading. It is searching for the path in the webserver but not in the user desktop.
You need to provide a way for the client to send the file to the server. The app is running on your web server which has its own file system. This server will not have direct access to clients' file system (this would be a huge security concern).
Sounds like you are trying to develop this as if it is a local app on the client's machine. This is not the case because you deployed part of the app to your web server. Think of your app as two pieces. Server side application / client side application. You need to create a way for these two to communicate with each other in a secure manner.
What you are looking for can be done with a REST endpoint on the server side where a client can send the file to the server via a POST request.
Basically the client side of the app (your webpage) could prompt the client to select a file on their machine and then send the contents of the file(s) via HTTP POST to the server side of your app where your python code performs whatever operations you want. The server app could even send a response back to client (the combined files maybe).
Something like this is what you ultimately need to do... note that in this link they developed BOTH server/client parts of their app in python. In your case you have created a webpage client frontend that will run in a browser. You would need to add some code to your webpage to have the user upload a file from their machine and send it to the server.
Sending files between client - server through TCP socket in python?

Streaming values in a python script to a wep app

I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App.
I don't know how to proceed to link the WebJob to the web app.
Any ideas ?
You have two main options:
You can have the WebJobs write the values to a database or to Azure Storage (e.g. a queue), and have the Web App read them from there.
Or if the WebJob and App are in the same Web App, you can use the file system. e.g. have the WebJob write things into %home%\data\SomeFolderYouChoose, and have the Web App read from the same place.
You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Otherwise you need to connect with a web socket and stream the data over a normal socket connection.

python (flask) redirect request via client

I have been trying to do something which I think should be pretty simple. The situation is as follows. The client makes a request for a resource on my web server. My flask application processes the request and determines that this resource is located at a certain location on another web server and the client should make a request of that server instead.
I know I can use the redirect function to tell the client to send a request to the remote location, but my problem is that the remote location is the Amazon Glacier servers. These servers require a request to be made in a certain way, with a special signature (see http://docs.aws.amazon.com/amazonglacier/latest/dev/amazon-glacier-signing-requests.html). My flask application knows how to go about the business of making these requests in the required way. I essentially want to know if it's possible to send a response to my client saying, send this request (generated by my application, with all the required signing) to the Amazon server?
Any ideas?
If the request can be encoded with get params like
http://www.redirecturl.com/?param1=bla&param2=blub
then it should work no problem. Just construct the request as a string and pass it to redirect().
As far as i know, you can't tell a client to send specific headers to a HTTP redirect URL.
Hitting the Glacier URL serverside would be the easiest. Using javascript on the clientside would only work if Glacier is implementing CORS.

bottle framework: getting requests and routing to work

I have written a webapp using traditional cgi. I'm now trying to rewrite it with bottle
The page is simple...the user fills out a form, hits submit and the data object is sent to a python script that used to live in my cgi-bin
The python script generates an image, and prints the url for that image out to standard out
On callback, I use javascript to display the newly generated image on the page formatted with html.
The issue that I'm having with bottle is getting the image-generating script to execute when it receives the post request. I'm used to handling the post request and callback with javascript (or jquery). should I be using a bottle method instead?
I actually resolved the issue. The Bottle framework tutorial encourages first-time users to set up the server on a high port (to avoid conflict with apache, etc) for development. I was missing two parts of the process: 1. import the python script so that it can be called from the main bottle file 2. in the main bottle file, add a route to the api link (for the javascript to work) I'm not sure if I would have had to add the route if I was running the server on port 80

Categories