Can we make a website with just HTML and python?
If so, how?
EDIT: Thank you everyone for replying, this is what I learnt from this post:
I can handle the backend with python(with django or flask), but to make a good looking frontend, I would have to use css and javascript, thank you.
Python web application - Stack Overflow
Creating a web application using Python
Using python to develop web application - Stack Overflow
How to build the front end of a web app if you only know python?
Videos
If you don't need Django, try web.py
http://webpy.org/
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'world'
return 'Hello, ' + name + '!'
if __name__ == "__main__":
app.run()
Sure! For example,
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
this is a web app -- if you save it into a file in an appropriate directory of a machine running a web server and set the server's configuration properly (depending on the server); the article I pointed to specifically shows how to deploy this web app to Google App Engine, but just about any web server can serve CGI apps, and this is a simple example thereof.
Of course, CGI has its limits, and you can use more sophisticated approaches (still short of a framework!) such as WSGI (also universally supported, if nothing else because it can run on top of CGI -- but in most cases you can also deploy it in more advanced ways) and possibly some of the many excellent utility components you can deploy with WSGI to save you work in coding certain parts of your apps.
Hello Everyone, I need some help with the following ? I am creating a very basic python web application. I will be writing the application in Python , what I have some doubts as how will I run it in a website as MVP. I don't know Angular JS and Javascript.
-
What front end should I use
-
What backend should I use
-
How many components will it take to run the Python application on a website..
Now that everyone has said Django, I can add my two cents: I would argue that you might learn more by looking at the different components first, before using Django. For web development with Python, you often want 3 components:
Something that takes care of the HTTP stuff (e.g. CherryPy)
A templating language to create your web pages. Mako is very pythonic and works with Cherrpy.
If you get your data from a database, an ORM comes in handy. SQLAlchemy would be an example.
All the links above have good tutorials. For many real-world use-cases, Django will be a better solution than such a stack as it seamlessly integrates this functionality (and more). And if you need a CMS, Django is your best bet short of Zope. Nevertheless, to get a good grasp of what's going on, a stack of loosely coupled programs might be better. Django hides a lot of the details.
Edited 3 years later: Don't use mod_python, use mod_wsgi. Flask and Werkzeug are good frameworks too. Needing to know what's going on is useful, but it isn't a requirement. That would be stupid.
Don't lookup Django until you have a good grasp of what Django is doing on your behalf. for you. Write some basic apps using mod_python and it's request object. I just started learning Python for web-development using mod_python and it has been great.
mod_python also uses a dispatcher in site-packages/mod_python/publisher.py. Have a ganders through this to see how requests can be handled in a simple-ish way.
You may need to add a bit of config to your Apache config file to get mod_python up and running but the mod_python site explains it well.
Copy<Directory /path/to/python/files>
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>
And you are away!
use (as a stupidly basic example):
Copydef foo(req):
req.write("Hello World")
in /path/to/python/files/bar.py assuming /path/to is your site root.
And then you can do
Copyhttp://www.mysite.com/python/files/bar/foo
to see "Hello World". Also, something that tripped me up is the dispatcher uses a lame method to work out the content-type, so to force HTML use:
Copyreq.content_type = 'text/html'
Good Luck
After you have a good idea of how Python interacts with mod_python and Apache, then use a framework that does all the boring stuff for you. Up to you though, just my recommendation
Suppose you want to create a web app that contains a dashboard with analytics that will serve thousands of users. It needs also user authentication, subscription models, payment and everything needed for SaaS service. You have just one month for the MVP.
You code in python so it’s easy to build the backend. But if you’re alone, what would you choose as front end?
Here’s a few options that I thought:
-
Use a Python template with Flask/Django (Soft UI dashboard)
-
Use streamlit framework
-
Learn a JavaScript framework (Next.js, React ?)
-
No-code tools (Bubble, Webflow)
Anything else? What would you choose?