newbie here in need of help.
Using App Inventor amd App Engine. Learning python as i go along. Still early days. Need to post text data from AI to app engine, save in blob store as file (.xml), to be emailed as an attachment.
Am able to send pictures using Shival Wolfs wolfwebmail2, and am sure with a bit of playing with the code i can change it to save the text post as a file in blob store to do the same operation.
As stated newbie learning fast.
Many thanks in advance for any pointers.
The solution I found was to do nothing with shival wolfs code on app engine, and to replace the 'postfile' block in the app inventor code with a 'posttext' block with the text you want to send attached to it. Also change the filename variable to the name you want the file called including file type (i.e. .xml, .csv, .txt etc). This appears to work for me.
Related
For a Python web project (with Django) I developed a tool that generates an XLSX file. For questions of ergonomics and ease for users I would like to integrate this excel on my HTML page.
So I first thought of converting the XLSX to an HTML array, with the xlsx2html python library. It works but since I can’t determine the desired size for my cells or trim the content during conversion, I end up with huge cells and tiny text..
I found an interesting way with the html tag associated with OneDrive to embed an excel window into a web page, but my file being in my code and not on Excel Online I cannot import it like that. Yet the display is perfect and I don’t need the user to interact with this table.
I have searched a lot for other methods but apart from developing a function to browse my file and generate the script of the html table line by line, I have the feeling that I cannot simply use a method to convert or display it on my web page.
I am not accustomed to this need and wonder if there would not be a cleaner method to display an excel file in html.
Does it make sense to develop a function that builds my html table script in str? Or should I find a library that does it? Maybe there is a specific Django library ?
Thank you for your experience
I'm developing my Django website since about 2 months and I begin to get a good global result with my own functions.
But, now I have to start a very hard part (to my mind) and I need some advices, ideas before to do that.
My Django website creates some PDF files from HTML templates with Django variables. Up to now, I'm saving PDF files directly on my Desktop (in a specific folder) but it's completely unsecured.
So, I installed another web application which is named LogicalDoc in order to save PDF file directly on this application. PDF files are created and sent to LogicalDoc.
LogicalDoc owns 2 API : SOAP and REST (http://wiki.logicaldoc.com/rest/#/) and I know that Django could communicate with REST method.
I'm reading this part of Django documentation too in order to understand How I can process : https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
I made a scheme in order to understand what I'm exposing :
Then, I write a script which makes some things :
When the PDF file is created, I create a folder inside LogicalDoc which takes for example the following name : lastname_firstname_birthday
Two possibilities : If the folder exists,I don't create a new folder, else I create it.
Once it's done, I send the PDF file directly inside the folder by comparing PDF name with folder name to do that
I have some questions about this process :
Firstly, is it possible to make this kind of things ?
Is it hard to do that ?
What kind of advices could you give me ?
Thank you so much !
PS : If you need some part of my script, mainly PDF creating part, I can post it just after my question ;)
An idea is pretty simple, however it always requires some practice.
I strongly advice you to use REST api and forget about SOAP as the only thing it can bring to you - is 'pain' :)
If we check documentation, document/create it gives next information.
Endpoint we have to communicate with.
[protocol]://[server]:[port]/document/create
HTTP method to use - POST
List of parameters to provide with your request: body,
document, content
Even more, you can test API by clicking on "Try it out" button and check requests in "Network" tab of your browser (if you open Developer Tools)
I am not sure what kind of metadata do you have to provide in 'document' parameter but what I know you can easy get an idea of what should be done by testing it and putting XML or JSON data into 'document' parameter.
Content is an array of bytes transferred to the server (which would be your file).
To sum up, a request to 'document/create' uri will be simple
body = { 'headers': {},'object': {},}
document = "<note>data</note>"
content=open('report.xls', 'rb') #r - reading, b - binary
r = requests.post('http://logicaldoc/document/create', body=body, document=document, content=content)
Please keep in mind that file transferring requests take time and sometimes you may get timeout exception. Your code will stop and will be waiting for response, so it may be a good idea to get some practice with asyncio or celery. Just keep in mind those kind of possible issues.
Here's what I want to do: Generate a url that I can put in my wordpress blog which will let users view a big text file. I don't know how I can generate this url. I was inspired by websites like Flickr which generate urls for images and was hoping there is a corollary for just text files.
I was taking the MITx 6.00.1x Python course, and one assignment had us refer to a text file that the professor had uploaded onto his course site. So the text file has a url:
https://courses.edx.org/c4x/MITx/6.00.1x_5/asset/words.txt
Not sure if this url is available to non members.
Is there a way I can upload this file to a universal url that anyone can access for free?
Kind regards,
Spencer
The way this works is actually supplying the path to the text file (in this case words.txt) on the web server. When you click that link, you're going from the root through several directories and accessing that file.
If you have access to the actual files on your wordpress blog, you can add a text file there and then give people the path to that file.
Otherwise, use a service such as Pastebin to provide the text file.
I want to email out a document that will be filled in by many people and emailed back to me. I will then parse the responses using Python and load them into my database.
What is the best format to send out the initial document in?
I was thinking an interactive .pdf but do not want to have to pay for Adobe XI. Alternatively maybe a .html file but I'm not sure how easy it is to save the state of it once its been filled in in order to be emailed back to me. A .xls file may also be a solution but I'm leaning away from it simply because it would not be a particularly professional looking format.
The key points are:
Answers can be easily parsed using Python
The format should common enough to open on most computers
The document should look relatively pleasing to the eye
Send them a web-page with a FORM section, complete with some Javascript to grab the contents of the controls and send them to you (e.g. in JSON format) when they press "submit".
Another option is to set it up as a web application. There are several Python web frameworks that could be used for that. You could then e-mail people a link to the web-app.
Why don't you use Google Docs for the form. Create the form in Google Docs and save the answer in an excel sheet. And then use any python Excel format reader (Google them) to read the file. This way you don't need to parse through mails and will be performance friendly too. Or you could just make a simple form using AppEngine and save the data directly to the database.
I am using Google App Engine to host a website where I want users to be able to upload any video and then I want to use flowplayer to display it, which requires MP4 and webm formats to support all browsers. I have it working correctly where a user uploads a video and then I can serve it but I need to convert it into those two formats so that I everyone can view the video.
Is there any Python project I can import to do the conversion on App Engine or any resources showing how I can do it with something like Google Compute Engine? I need it to be done automatically on the server and most projects that look stable for this in python are written to by done by command line on a personal computer.
I'm not sure about Google App Engine, but you may want to look into using FFMPEG. I am currently hosting a site on heroku and have been able to use it spawning a task that will automatically grab an image from the uploaded video for display and convert the uploaded file to mp4. In order for conversion to mp4, you will need a compilation using libx264. I am no expert on this, but it may be something you want to look into if you haven't already. In my app on heroku, I am able to convert uploads to mp4, but it has definitely taken some time to figure out the right configuration and it still takes longer than I would like. However, I am also a fairly new developer and this is my first app ever created, so it might be easier for you to get working the way you want it.