apply form data from Django website to .exe file to generate link - django

I have built a Django website to accept data submitted from a user input form (an e-book application website). Upon application by the user, I could see their application on the backstage of the website and approve their application. This website is used only for several people.
I want to add a function like this:
The users who have accounts on this website could submit a request to download the e-book, in which they should write the details (author, year.... ) of the e-book.
I have already made an .exe file, which could accept parameters (author, year...) to generate a .txt file (the e-book). I want to create an auto parameter passing function in my Django website. when I approve the users' application for the e-books on my website, the parameters they entered should be passed to the .exe file to generate the .txt file automatically and save this .txt file on the server.
At the same time, a link that is linked to the storage position of the .txt file should be shown to the user so they could download the .txt file generated.
I have tried to deploy my Django project to pythonanywhere, but it's a linux server and so the .exe file could not be run on it.
I have these 2 questions:
Are there any free Windows server options to deploy my Django website to so that I could let the .exe file run in the backstage?
How to achieve the functionality of passing the parameters that the user entered to the .exe file automatically and show the link to the user for downloading (I have finished all the other functionality of the website, including storing the parameters they entered to the sqlite database)?

Related

Launch Windows Photos app from C++ for a list of files

I want to launch the Windows Photos app from C++ for a list of image files.
Problem with Photos app is that, if it is launched using ShellExecute (for a single file) it disables the next and previous buttons, even if the folder contains other images.
I have tried using IApplicationActivationManager COM interface to launch the photos app
IApplicationActivationManager->ActivateApplication is launching the app without any file, but IApplicationActivationManager->ActivateForFile is failing with error: 0x80270255 - This app has mulitple extensions registered to support the specified contract. Activation by AppUserModelId is ambiguous.
Is there a way to launch the app with list of files or launch the app first and then send the list of files to open.

Uploading text file in server using django

I have a created a website which allows users to login by giving user name and password..Now i want to make an option which will allow the file from local machine to upload to a server.How can i do this?
Follow documentation on File Uploads

How do web apps receive/process uploaded images?

I can't seem to wrap my head around it. How do websites create forms for image uploads, store, and process it for display on their sites? My current situation is with django storing images.
You place a <form> on your page. It can have different inputs in it, like text, numbers, etc. There is also file input. Then the user submits the form and all data is sent to the webserver. The webserver, basically, receives the file as an array of bytes. You can read more about it here.
In case of Django you'll receive this data in request.FILES. You'll get name, size and other data of the file selected by user. You can then save it on disk or in your database. Read about Django-specific things here.
In general (in a very resumed/simplistic way):
A web page renders a form with an widget in it.
When you tell the browser what's the file you want to upload, it prepare an HTTP request to the webserver in which it stores the binary data of the file.
The request is sent to the web server through a TCP connection.
The server takes the request, see the file an decides what to do with it (depending on configuration files)
Later, the program handling the request, ask the global variables of the server (or something like that) what the heck it did with it files
The server give it the address where it was stored
The app do the rest of the job with the file uploaded :)
In Django:
Three first step are the same
The server ask django what to do with the file
Depending on settings.py the file is uploaded to memory or to a temporary file in disk
The application handles the file accessing it to request.FILES dictionary in your view
When you have it, you can pass it to your models, forms or do whatever you want.
If you want to go deeper with Django file uploads, this section of the documentation is really good. You can take a look at it.
Hope this helps!

Django - Upload file without using form

I have a small email client. I would like to be able to upload files without having to submit a form. So, I have my email form. I would like to, whenever I use the file input button on my form, that file would be uploaded without any reload of the page. The goal is to be able to upload multiple files without a reload of the page, something similar to what happens in GMail.
Every time you click the file input and choose a file, a small progress bar appears with the upload progress, and the page is not reloaded.
I am guessing some JS/Ajax library might help me achieve this? I am using HTML5.
Thank you
Blueimp has a great jQuery-based throttling file uploader.

How to save upload files to another server

I'm currently using django. And now I need to save a file uploaded by a user to another server which is not the one that serves the django application. The file will be saved to file system not the database. Could somebody tell me how to do this?
Default Django behavior is to save file on the filesystem, not the database itself).
You have several options how to do this, the simplest one is to have a filesystem exported from you "other" machine and mounted on the machine with the django application.
For the filesystem export you can use NFS, MogileFS or GlusterFS (which I'm using) or many more :). If you do not need real-time save&serve, simple rsync may be an option too.
Second option is to utilize existing django mechanisms StogareAPI. There are already available different storage backeds you can use and may be helpful for you (e.g. ftp).
This wont work out of the box, you need to have a mechanism(write some code) to queue the files that are uploaded through django application, then use a middleware(can be in python) to transfer files from queue to your file server. so flow is basically like this:
Accept the uploaded file via django app.
django app. writes the file info(its temporary path and name) to a queue
A middleware app reads the next file in queue.
The middleware app use some transfering protocol(sftp, scp, ftp, http etc...) to copy the file to file server.
Middleware app deletes the file from where django app is hosted so django server dont have a copy of the file.