This question is related to backend development. I am an intermediate-knowledge university student working in this field.
For my project, I am developing a website that alerts the user if something's missing from its place. For example, a valuable thing is placed under the scrutiny of CCTV. Then I detect the object using Image processing and as the thing is gone, I want to raise an alert.
I have done Image processing and am able to detect the presence/absence of the object on my local machine. I want to deploy such a thing on the server for end-consumer usage.
But then how to do this on the server because then two things need to be done at once, the video needs to be continuously processed, and when there is an alert, a notification should be kept in the notification feed (just like any social media platform), while also continuously monitoring the video.
I am familiar with Django.
In a nutshell, I want to understand how social media websites, also sometimes show notifications while we are scrolling the feed. How two things are managed at one time?
Thank you for the help.
Regards.
Related
I would like to make a web application where a user can:
click a button on a webpage to create a **random video (with moviepy)
play that video back on the webpage
click the button again to create a new **random video that replaces the existing one
** The random video will be created with a python/moviepy script that downloads a bunch of random video clips from the internet to a directory on my computer. It then compiles them into one video (.mp4 file).
I've done the python script bit already which successfully creates the video file.
To make the web app bit I have been recommended django and that's where I'm stuck!
So far I have installed django and got to grips with the basics .. I have a home page that says "Hello world".
My question is where do I go from here?
How do I connect my python/moviepy script with django?
What steps, apps, components etc, within django should I look into to make this thing?
I'm new to coding and looking for some guidance.
Thanks!
If you create a model with FileField then your moviepy script should upload videos into that field, that field can save the video in a specified directory in MEDIA_ROOT(you can store your post based on date) then that field will store the URL to it (you need to specify MEDIA_URL in settings.py). You can define some sort of IDs to them, if video privacy is not important, then you can use the model IDs. These IDs can be obtained trough Path converters .
At the client-side, javascript is needed. Simply running the script in view is possible, but then the user will need to wait for the response (and the browser should run into time-out).
You should look at server-sent events. With Vue.js you can easily display a loading element while waiting for the event (a video to be generated) and then download and switch to the video (see Django CRUD application tutorials). The python script can run asynchronously (you call it in the view).
It is a lot, I know.
Actually I'm going to learn these now, sorry for mistakes.
As I see, Django is for complex sites, you should look for Flask instead.
(I am learning Django and I know nothing about Flask, so I`ll go with it)
Here is the needed setup:
define the urlpatterns for handling the URLs
create a model for storing your video
create a django template for your page (html)
define a view for rendering out the template (passing the video)
maybe some css to design it
You can run your video generator(in the view) at every reload and override existing video(in this case you don't even need a model) or you can save the generated videos and capture the IDs in the URLs (for example: https://yoursite.com/1), in this case, the videos remain shareable.
If you go with the first option and sharing videos is not important for you then you could write a simple html page with a video and a button. The button can trigger a javascript function to run the video generator python script and refresh the page(the video is overridden), you may need to wait to the script otherwise the old video can load.
Restful API is a more advanced way to refresh the video, without reloading the page.
After these, you can deploy your page using an Apache server for example.
I tried to give you some guidelines (I am learning this on my own)
Hope that it helped :) There are tutorials for these.
I am new at this part of web developing and was trying to figure out a way of creating a web app with the basic specifications as the example bellow:
A user1 opens a page with a textbox (something where he can add text or so), and it will be modified as it decides to do it.
If the user1 has problems he can invite other user2 to help with the typing.
The user2 (when logged to the Channel/Socket) will be able to modify that field and the modifications made will be show to the user1 in real time and vice versa.
Or another example is a room on CodeAcademy:
Imagine that I am learning a new coding language, however, at middle of it I jeopardize it and had to ask for help.
So I go forward and ask help to another user. This user access the page through a WebSocket (or something related to that).
The user helps me changing my code and adding some comments at it in real time, and I also will be able to ask questions through it (real time communication)
My questions is: will I be able to developed certain app using Django Channels 2 and multiplexing? or better move to use NodeJS or something related to that?
Obs: I do have more experience working with python/django, so it will more productive for me right know if could find a way working with this combo.
This is definitely possible. They will be lots of possibilities, but I would recommend the following.
Have a page with code on. The page has some websocket JS code that can connect to a Channels Consumer.
The JS does 2 simple things. When code is updated code on the screen, send a message to the Consumer, with the new text (you can optimize this later). When the socket receives a message, then replace the code on screen with the new code.
In your consumer, add your consumer to a channel group when connecting (the group will contain all of the consumers that are accessing the page)
When a message is received, use group_send to send it to all the other consumers
When your consumer callback function gets called, then send a message to your websocket
So excited for My first post in Stackoverflow! :)
Q: I'm recording and processing sounds using python (pyaudio + scipy). now one important thing that I need, is the ability to streaming this processed audio(that's in form of python Variables),Over wifi (or bluetooth). User clients that connecting to my server, should can play that sound for Live. But really I haven't any background about web/net based application in python.
I'm thinking this way :
Maybe linux should establish a server(become a Access point) and give access to users for playing streamed audio using a simple html page! This webpage maybe need just a play button that when client click on that,and live streaming audio will be played!
Can anybody guide me in right way?
I am building a django app where users submit data which is displayed on home page.
As there is not going to be huge traffic, I personally want to block data based upon the IP address!
Now, I need to know the IP address of the user! How do I get it?
I searched a lot on web and specifically on this site, but didn't get a simple and proper answer that does the job.
can anyone tell me how to do it?
Is there any API stuff present that helps me block specific users (may be locations/ continents - I guess GeoDjango is there for it).
I'm a Social Media Manager for Musicians and Bands across the globe, and have run in to a snag and am looking for anyones opinion who can help on the matter!
I'm using a service called Ping.FM that I use for updating status messages across multiple social networks. Unfortunately, it doesn't seem the development team is in the works anymore and two of the networks no longer work, Tagged and MyYearBook. Now, these two services have no custom service API, email update, or really any kind of function for updating status messages other then using a mouse, keyboard, and browser.
Now the second part. I have a shared web host (HostGator) that I use to run and leave Python scripts running to do my bidding whenever needed. What I'm thinking of is writing a script that will monitor an email account. When an email is received, it'll post the body as a status message.
Now the tricky part, how to post the status message. The shared host is all terminal only, no GUI. If there was a GUI, I would just use something like iMacro with Firefox and a Python script to alter it in order to post the status messages. Unfortunately though, no GUI, so as far as I'm aware it's not possible.
Is there any method of doing an idea like this, but without a GUI? Something terminal based, that can achieve the same idea? Any help is appreciated, thanks in advance!
All websites have an API, called HTTP. You can use mechanize to access it, so long as it doesn't use JavaScript for dynamic display.