Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
web development environment Ubuntu
#1
Hello Python Community,
i was asking about web Development in Python on Ubuntu 14.04 is there any link or any tips for it
and how i start learning and building websites with Python on Ubuntu does it need a local host like Php and how i can get it.
thank you for your help in advance.
Reply
#2
There are multiple frameworks for website creation for python. How you learn would depend on which framework you chose.

The largest framework is Django
There is Flask which is a microframework that can be for a single page to a medium sized project.
There is also bottle framework.
Then there is WSGI for things like a single page or two.

and there are a ton more frameworks

How is your server currently setup? Is this a server at all or just a home desktop for testing? Are you looking at creating a large project or a single page or two?

I would suggest Flask as its the middle of the road area and can do well for small or large projects combined. You can check out our web dev tutorials which consists currently mostly of Flask tutorials.
Recommended Tutorials:
Reply
#3
(Aug-22-2017, 11:37 AM)AhmadMWaddah Wrote: does it need a local host like Php and how i can get it.

In addition to metulburrs hints: Yes, you do need a "local host" which he calls a server. This is where python runs, as it is not installed on your websites' visitors' computers. You can start with a small private server at your home and/or rent a public server which supports python
Reply
#4
If you are using Ubuntu you already have a localhost. It's called just like that - localhost. Run the server and in your browser type: http://localhost:8080 or http://127.0.0.1:8080. For example. The port could be different.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
Flask and Django comes with build in web-server(Flask: http://127.0.0.1:5000, Django: http://127.0.0.1:8000/) that run on localhost.
This mean that you can do all development local,
if finish with something you want to share with the word. 
Find a Python friendly host(PythonAnywhere, Digital Ocean, Heroku, AWS Lambda).
Reply
#6
The embedded server in each framework ( Django, Flask, Bottle ) is only for development. For production use Apache, Nginx or some Twisted built custom server.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
(Aug-22-2017, 12:05 PM)metulburr Wrote: The largest framework is Django
There is Flask which is a microframework that can be for a single page to a medium sized project.

How is your server currently setup? Is this a server at all or just a home desktop for testing? Are you looking at creating a large project or a single page or two?

I would suggest Flask as its the middle of the road area and can do well for small or large projects combined. You can check out our web dev tutorials which consists currently mostly of Flask tutorials.

thanks for support metulburr.,
i am still learning Python and i wanna install the server on my laptop to start practicing it.
do dijango support small project or will be so bad and hard.,? as it is the largest so its the best., to get more experience of the best,.

(Aug-22-2017, 01:25 PM)wavic Wrote: If you are using Ubuntu you already have a localhost. It's called just like that - localhost. Run the server and in your browser type: http://localhost:8080 or http://127.0.0.1:8080. For example. The port could be different.
(Aug-22-2017, 10:18 PM)snippsat Wrote: Flask and Django comes with build in web-server(Flask: http://127.0.0.1:5000, Django: http://127.0.0.1:8000/) that run on localhost.
This mean that you can do all development local,
if finish with something you want to share with the word. 
Find a Python friendly host(PythonAnywhere, Digital Ocean, Heroku, AWS Lambda).

yes, i am using Ubuntu 14.04., when i had information about Php i installed (( LAMP )) server for localhost to practice it.
About Python how i can use the localhost? is it after i install the framework it will get me the localhost or i need to install server like i did in (( LAMP )).

again thank you very much for supporting guys.
Reply
#8
You get the so called localhost with the installation of the system. You have it already. Don't worry about it. Just to check it and chill run this in the terminal:

python -m SimpleHTTPServer
or

python3 -m http .server
Then, open the browser and type: http://localhost:8000 and hit ENTER. It will open a web page with all the files and folders - browsable. This command will create a web server and will serve the directory from which you run the command.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#9
(Aug-23-2017, 12:25 PM)AhmadMWaddah Wrote: or i need to install server like i did in (( LAMP )).
No,you do not need LAMP,WAMP,XAMPP...ect at all.

Here is basic setup you can try:
pip install Flask 

Folder setup:
my_page\
  |-- app.py\
  templates\
    |-- index.html
    |-- about.html
  static\ # CSS,JS,images ..ect goes in here in own folders
    
Files:
app.py
from flask import Flask, render_template
 
app = Flask(__name__)
@app.route('/')
def index():
   return render_template("index.html")
 
@app.route('/about')
def about():
   return render_template("about.html")
 
if __name__ == '__main__':
   app.run(debug=True)
index.html
<!doctype html>
<html>
  <head>
    <title>Some title</title>
    <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/style.css') }}" />
  </head>
  <body>
    <div id="start">
      <h1>Start page</h1>
      <ul>
        <li class="page_1"><a href="/about">About</a></li>
      </ul>
    </div>
  </body>
</html>
about.html
<!doctype html>
<div class="foo">
  <h1>The About Page</h1>
  <a href="http://flask.pocoo.org/">Learn Flask</a>
</div>

Now have a basic setup and can test it out.
Run python app.py this start the build in web-server.
In browser http://127.0.0.1:5000/
So now should see index page with a link to about page.

Quote: For production use Apache, Nginx or some Twisted built custom server.
Yes that right,and some host do all all server setup,so only need to upload files.

A quick overview over host that a posted.
PythonAnywhere: they to all server setup(they use uWSGI  and Nginx).
All that is required of you is to upload files git clone repo on there command is the recommend  way.
Can also use there web interface to upload files.

AWS Lambda: lets you run code without provisioning or managing servers.
You pay only for the compute time you consume.

Digital Ocean you are the boss over everything,start from blank distro eg Ubuntu.
You do all server setup,here i prefer Gunicorn and Nginx(not Apache).

Heroku: Only setup Gunicorn,they setup Nginx.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Eclipse Python We development Environment Adelton 3 4,569 Feb-16-2017, 08:52 PM
Last Post: Adelton

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020