Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,807 members, 7,810,100 topics. Date: Friday, 26 April 2024 at 08:46 PM

Need Help With Python Server Side Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Need Help With Python Server Side Programming (1376 Views)

How To Write A Middleware In Express.js (Node Server Side Framework) / [Advice] For New Programmers, what server-Side Programming Language Is The Best? / PHP Or Python For Server-side Scripting (2) (3) (4)

(1) (Reply) (Go Down)

Need Help With Python Server Side Programming by ProNdubuisi: 6:26pm On Dec 12, 2016
Hello world, does anyone here write sever side code with python? just learnt the language and want to go into web dev with it, but all i see is Django tutorials online, i dislike frame works. Do you know how i can hard code Python like you hard code php, html css and the rest? i need someone who has done it before to walk me through
Re: Need Help With Python Server Side Programming by 4kings: 8:18pm On Dec 12, 2016
Following...
I need to know this too.
But frameworks are helpful most times.
Re: Need Help With Python Server Side Programming by Dreadlord: 9:21pm On Dec 12, 2016
In my opinion, I am I don't see why you want to reinvent the wheel. I bet you don't use class libraries, you don't even use a programming language. You code in Binary. You don't even need code, you process data manually since you are a boss man.

3 Likes

Re: Need Help With Python Server Side Programming by kudaisi(m): 9:35pm On Dec 12, 2016
ProNdubuisi:
Hello world, does anyone here write sever side code with python? just learnt the language and want to go into web dev with it, but all i see is Django tutorials online, i dislike frame works. Do you know how i can hard code Python like you hard code php, html css and the rest? i need someone who has done it before to walk me through

[b]Do I have to use a web framework?
[/b]Whether or not you use a web framework in your project depends on your experience with web development and what you're trying to accomplish. If you are a beginner programmer and just want to work on a web application as a learning project then a framework can help you understand the concepts listed above, such as URL routing, data manipulation and authentication that are common to the majority of web applications.

On the other hand if you're an experienced programmer with significant web development experience you may feel like the existing frameworks do not match your project's requirements. In that case, you can mix and match open source libraries such as Werkzeug for WSGI plumbing with your own code to create your own framework. There's still plenty of room in the Python ecosystem for new frameworks to satisfy the needs of web developers that are unmet by Django, Flask, Pyramid, Bottle and many others.

In short, whether or not you need to use a web framework to build a web application depends on your experience and what you're trying to accomplish. Using a web framework to build a web application certainly isn't required, but it'll make most developers' lives easier in many cases.

1 Like

Re: Need Help With Python Server Side Programming by greatface(m): 9:40pm On Dec 12, 2016
I bet You are better off with frameworks.

You "may" regret reinventing the wheel unless it is for learning purposes or some other better reasons.
Re: Need Help With Python Server Side Programming by 4kings: 9:41pm On Dec 12, 2016
Dreadlord:
In my opinion, I am I don't see why you want to reinvent the wheel. I bet you don't use class libraries, you don't even use a programming language. You code in Binary. You don't even need code, you process data manually since you are a boss man.
Haba this is too far.
He just wants to know how to do it himself.
Me too.. That knowledge could be useful.
Re: Need Help With Python Server Side Programming by Dreadlord: 10:05pm On Dec 12, 2016
4kings:

Haba this is too far.
He just wants to know how to do it himself.
Me too.. That knowledge could be useful.
My bad, I I just get really frustrated when someone thinks it's way cooler to write a hello world application in treefrog than writing a complex web application in Ruby or php.
OP, my apologies. I you should try oriely's programming Python 4th edition it has what you are looking for. Once again sorry.
Re: Need Help With Python Server Side Programming by 4kings: 10:23pm On Dec 12, 2016
Dreadlord:

My bad, I I just get really frustrated when someone thinks it's way cooler to write a hello world application in treefrog than writing a complex web application in Ruby or php.
OP, my apologies. I you should try oriely's programming Python 4th edition it has what you are looking for. Once again sorry.
Thanks.
I'll try downloading the pdf
Re: Need Help With Python Server Side Programming by ProNdubuisi: 7:28am On Dec 13, 2016
Dreadlord:
In my opinion, I am I don't see why you want to reinvent the wheel. I bet you don't use class libraries, you don't even use a programming language. You code in Binary. You don't even need code, you process data manually since you are a boss man.
I just want to learn, if everyone uses frameworks, who will code frameworks Keanu? Thanks for stopping by

2 Likes

Re: Need Help With Python Server Side Programming by ProNdubuisi: 7:32am On Dec 13, 2016
Dreadlord:

My bad, I I just get really frustrated when someone thinks it's way cooler to write a hello world application in treefrog than writing a complex web application in Ruby or php.
OP, my apologies. I you should try oriely's programming Python 4th edition it has what you are looking for. Once again sorry.
will make the download ASAP thanks
Re: Need Help With Python Server Side Programming by kudaisi(m): 9:23am On Dec 13, 2016
If you must do web development without a framework in python, you will need to implement the Web Server Gateway Interface (WSGI. According to Wikipedia
It is a specification for simple and universal interface between web servers and web applications or frameworks for the Python programming language.

PEP3333 is the most recent version of this specification available on the python official website;
The document specifies a proposed standard interface between web servers and Python web applications or frameworks, to promote web application portability across a variety of web servers.
Here's a quote from the "Original Rationale and Goals (from PEP 333)"
Python currently boasts a wide variety of web application frameworks, such as Zope, Quixote, Webware, SkunkWeb, PSO, and Twisted Web -- to name just a few [1] . This wide variety of choices can be a problem for new Python users, because generally speaking, their choice of web framework will limit their choice of usable web servers, and vice versa.

By contrast, although Java has just as many web application frameworks available, Java's "servlet" API makes it possible for applications written with any Java web application framework to run in any web server that supports the servlet API.

The availability and widespread use of such an API in web servers for Python -- whether those servers are written in Python (e.g. Medusa), embed Python (e.g. mod_python), or invoke Python via a gateway protocol (e.g. CGI, FastCGI, etc.) -- would separate choice of framework from choice of web server, freeing users to choose a pairing that suits them, while freeing framework and server developers to focus on their preferred area of specialization.

This PEP, therefore, proposes a simple and universal interface between web servers and web applications or frameworks: the Python Web Server Gateway Interface (WSGI).
https://www.python.org/dev/peps/pep-3333/

1 Like

Re: Need Help With Python Server Side Programming by kudaisi(m): 9:31am On Dec 13, 2016
However, you can still reduce the overhead of implementing every bit of the specification by yourself (I strongly suggest you understand it though) by using existing libraries. One of such is Werkzeug - The Python WSGI Utility Library, and it's the most popular that I know of. There are other option asides Werkzeug so you might want to check them out too, a little googling should help.
http://werkzeug.pocoo.org/

1 Like

Re: Need Help With Python Server Side Programming by lordZOUGA(m): 11:47am On Dec 13, 2016
If you are interested in returning HTML from a server just like most webservers, then you can just create a server listening to a port and return a bunch of strings from the server (sounds easy right?).

The problem is that you also have to build HTTP headers and manage I/O between server and clients (this is unbelievably complex).

Frameworks are helpful because they have already implemented most of these features reliably.

I encourage you to try building a webserver from scratch, it will make you appreciate the usefulness of Frameworks.

2 Likes

Re: Need Help With Python Server Side Programming by kudaisi(m): 12:12pm On Dec 13, 2016
lordZOUGA:
If you are interested in returning HTML from a server just like most webservers, then you can just create a server listening to a port and return a bunch of strings from the server (sounds easy right?).

The problem is that you also have to build HTTP headers and manage I/O between server and clients (this is unbelievably complex).

Frameworks are helpful because they have already implemented most of these features reliably.

I encourage you to try building a webserver from scratch, it will make you appreciate the usefulness of Frameworks.
The environment variable his server has to cater for (and this is just a tip of the iceberg)
REQUEST_METHOD
The HTTP request method, such as "GET" or "POST" . This cannot ever be an empty string, and so is always required.
SCRIPT_NAME
The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server.
PATH_INFO
The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash.
QUERY_STRING
The portion of the request URL that follows the "?" , if any. May be empty or absent.
CONTENT_TYPE
The contents of any Content-Type fields in the HTTP request. May be empty or absent.
CONTENT_LENGTH
The contents of any Content-Length fields in the HTTP request. May be empty or absent.
SERVER_NAME , SERVER_PORT
When combined with SCRIPT_NAME and PATH_INFO , these two strings can be used to complete the URL. Note, however, that HTTP_HOST , if present, should be used in preference to SERVER_NAME for reconstructing the request URL. See the URL Reconstruction section below for more detail. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required.
SERVER_PROTOCOL
The version of the protocol the client used to send the request. Typically this will be something like "HTTP/1.0" or "HTTP/1.1" and may be used by the application to determine how to treat any HTTP request headers. (This variable should probably be called REQUEST_PROTOCOL , since it denotes the protocol used in the request, and is not necessarily the protocol that will be used in the server's response. However, for compatibility with CGI we have to keep the existing name.)
HTTP_ Variables
Variables corresponding to the client-supplied HTTP request headers (i.e., variables whose names begin with "HTTP_" ). The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request.

1 Like

Re: Need Help With Python Server Side Programming by ProNdubuisi: 6:14am On Dec 14, 2016
Thanks guys for your researched inputs and criticisms. Keep them coming, will keep you posted if i hit a solution. Thanks once more.
Re: Need Help With Python Server Side Programming by ANTONINEUTRON(m): 8:10am On Dec 14, 2016
Then Get Ready To Configure Some Modules And Variable In Apache Or The Server Engine You'll Be Using

U Can Use Wsgi Or Mod_python Module

I Saw A Tutorial On Google On How To Configure Server To Run Python


Search "Configuring Apache(or Your Server Engine) To Run Python"

Practice The Steps On Your Pc

If Work, Get A Host That Let U Configure Your Server

Or A Host That Has Already Configure The Server For Python.

Even If U Re Even Using A Framework, You'll Still Configure Your Server If You Are Deploying

So U See, Everything Is Configuration
Simple And Complicated

2 Likes

Re: Need Help With Python Server Side Programming by logicab: 8:22am On Dec 14, 2016
CGI? That's been phased out since 1998.

https://en.m.wikipedia.org/wiki/Common_Gateway_Interface

1 Like

(1) (Reply)

Swapspace / Building An Ionic 3 Shopping Cart App With Firebase Realtime Database Part 2 / How Do I Write Cleaner Codes In Python?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 42
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.