Python Forum

Full Version: Python server(Django web site)/client(Python app) connection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is my situation:
I’ve got Django web site(url shortener) with its database. This database consists all data about url.
I'm going to make a simple Python program, that would work like my site: you give long url and it make short one, and it should write these 2 urls to my site's database.
I dont know anything about socket programming so I'm asking your help, guys.
Should I make a Python server in Django site and a client in Python app?
And what should I do if I want many people to use this app at the same time
Hi,

well, there are a couple of question in your post, but they are not really questions.

Quote: I dont know anything about socket programming so I'm asking your help, guys.
+
What leads you to the assumption that you need socket programming? To cut it short: you don't need it.

Quote: And what should I do if I want many people to use this app at the same time
Ask money from the people and get rich :D Seriously: what's the problem with that? As long as your server can handle the number of request, no worries. In case it can't -> upgrade the server. In case you ever reach the point where a single server can handle that anymore -> post again here.

What I don't get yet from you post: you say you have the URL shortner already as a Django app - than you should have the client application in the form of a web page already? So what do you mean exactly be "client in Python app"?

Regards, noisefloor
(Jul-05-2019, 10:02 AM)Junior_Pythoneer Wrote: [ -> ]Should I make a Python server in Django site and a client in Python app?
And what should I do if I want many people to use this app at the same time
How it works is that for all local development you use the build web-server that comes wit Django.
When finish and only if want to share with the world,then need a host.

A good tutorial from a good host DigitalOcean.
How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04

More recommendations here.
Running Django in the App Engine flexible environment
Guys, i read your answers and i understood that there's no need to use socket programming.
Here's what my app should do:
1. User write some data(long url)
2. These data go to Django server
3. Django server, using these data, make another data(short url) and saves it in database
4. Django server sends new data(short url) back to User
I read something about REST API, is it what i need, or not?
(Jul-05-2019, 03:00 PM)Junior_Pythoneer Wrote: [ -> ]1. User write some data(long url)
2. These data go to Django server
3. Django server, using these data, make another data(short url) and saves it in database
4. Django server sends new data(short url) back to User
I read something about REST API, is it what i need, or not?
All of this is still local development,so here you use the build in web-server that comes with Django.
Using REST is a internal choice you make,can use it or not.

So the point here is that you have all that's needed to make the web-app finish with Database.
Only when all is finish and think of sharing it with world,the need a host as posted over.
Then change out the build web-server,to something that is production ready eg Gunicorn with Nginx in front.
Hi,

 I read something about REST API, is it what i need, or not? 
Depends on how you want to do it. If the URL is entered on a HTML page delivered by Django -> not REST necessary.

If Django should receive a GET request with the URL only and should respond with the shortened URL -> you need a REST-type interface.

So basically you need to make up your mind how you want to do it.

If you go for REST: the are Python webframeworks like Hug which focus on REST APIs only. On what you described so far, I see no advantage in using Django specifically for your task.

Regards, noisefloor