I wish to create a website to compute simple stress calculations for machine design. I have attached a sample below. What tools do I need to build something like what I have shown in the attached image. I want the user to perform the calculation, save for later use and print it in the form of a report. Please note the items in boxes are user input.
Looks like you want to create a web app. If your language of choice is python, you can use the Django web framework. Web frameworks like Django and Ruby on Rails help organize your files for websites. You can create a web app using Django but all your python code will be running on the server. Any calculations would need to be sent as a request to the server and returned to the client. JavaScript runs on the client computer and would be better for your application. You can also store cookie data in the client computer to access later. In addition you should know some html and CSS to display your app. The html, CSS and JavaScript can all be implemented in the Django framework.
Related
I have a python script that continuously generates JSON object
{ time: "timestamp", behaviour: 'random behaviour'} and display it on stdout.
Now I want to build a web app and modify the script so that I can read continous data to my web page. I donno where to start from.
Well in details: I want a web API to have an on/off button and by clicking on it start reading the beahviour and on clicking off it stops.
I am very new to programming so please suggest me topics and ways I need to study/ look upon to make this app.
thanks
Here's a simple way I'd go about doing it:
Create a backend service that exposes the python script's output via HTTP. You can use any familiar backend programming language: python, java, .net etc to host a simple http web server, and expose the data.
Create a simple html page, that makes an ajax call to your backend service, pulls the data, and shows it on the page.
Later add your buttons, make the page nicer, responsive on other devices.
Topics to read depends on what you are missing above. My best guess based on your question is that you are not familar with front end programming. So read up on html, js, css and ajax.
I am making a program where I need to get information from a web server (I'm using Django) and then I'd send data back to the server.
The thing is I can only find ways to get information from the html page of the url I requested.
How could I use a Python script to get data from the web server? (like making a Django db query but outside Django, using only Python) I want to be able to get the information stored in Django without having to go directly to the website (that is, using a Python script).
Thanks in advance,
I guess you'll want to use a REST framework. The most used are django-rest-framework and tastypie
I need to develop a simple login page using Python language with two fields and a button, like:
Username, Password, Login
I know there are some beautiful Python frameworks like
Django, Grok, WebPy, TurboGears
which support web development using Python, but mine is a basic requirement consisting of only 3 screens (pages):
1st page - Login page (Redirects to 2nd page when login button is clicked)
2nd page - Page with records in the form of a list, with an option for adding new records (Redirects to 3rd page when "Add Records" button is clicked)
3rd page - Page with fields, which are saved as records for the list on 2nd page (After entering details and clicking Submit)
So, I have decided to develop the above functionality using Python without using any framework, so that I can have flexibility as well as write my own code.
Is it possible to create a login page using Python without using a framework?
I haven't worked on web services and don't know the basics of web development in Python.
If possible, can you provide me an example on how to create a login page using Python and achieve the functionality described above?
Firstly, it's good to learn how to do things without the frameworks, but if you're doing this for anything but educational purposes it's most likely a mistake to say "my requirements are too simple to bother with frameworks." What you describe is on the simpler end of the spectrum, but already I can see some complications you're probably glossing over.
Anyway, to implement your 3 pages, you will need:
a web server
2 static HTML files
python handlers for GET on 2nd Page, POST from 1st and 3rd Page
storage (either flat file or database)
Look at A Simple Python CGI Server Tutorial to get started, and there are more details at TutorialsPoint: Python - CGI Programming.
Your HTML forms just need to have method="POST" and action set to the URL you're serving from python for each form. Your POST handlers should do what they need to do and then serve a 302 redirect.
If you don't know the basics of python web development, you're going to have your hands full and should probably start with a single user flat-file system. Maybe you can even get away with storing that in memory for now. Then if/when that stops doing it for you, try sqlite. Configuring web servers is a pain, too, so if you can just stick with BaseHTTPServer.
Finally, load your records in another python endpoint, make some HTML for each, slap it in a big string with surrounding HTML, and serve that puppy.
You requirement is very trivial. Though people may suggest micro frameworks like flask, bottle I would say you should try Django and have a look at Django Admin Panel. I think it's possible for you to meet your requirement using the Django admin feature.
Updated
Have a look at this http://docs.python.org/howto/webservers.html
Without a framework and if you don't want to mess with CGI you can take a look at http://webob.org/ .
I need to create a simple web service, and am leaning towards the Python package soaplib.
I would also like to create a simple web page that can consume the web service. This will serve two purposes:
Allow for easier testing by multiple people including non-programmers.
Allow knowledgeable / power users to call the service directly in Production on a few occasions.
Any suggestions for creating this web page? Ideally, I want to generate it automatically and not craft it by hand. I have used this type of feature with Visual Studio .NET which autocreates a basic web page as part of the process of creating a web service.
Any ideas are appreciated. I'd prefer an automated solution based on soaplib but am open to any non-soaplib or non-Python solution as well.
Have you considered using REST (here or here)? I was creating small app using GAE and I wanted to have programmable interface for that too. So using exactly the same URLs I've created a web service (REST) which based on client accepted mime type answered either using json (for software) or html (for users). You have wide range of possibilities and it's lot cleaner that soap-based ws.
As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again. However what I would like to do is submit the data, have it stored in the datastore without the sending page being refreshed. It seems like a waste of traffic to have all the data sent back again.
Sounds like you want to look into AJAX. The simplest way to do this is probably to use the ajax functions in one of the popular Javascript libraries, like jQuery.
AJAX. If you want a specific resource concerning AppEngine -
http://code.google.com/appengine/articles/rpc.html (uses Python) is very good.
Here is a good link to understand Communication with Server on Google App Engine
Have a look at Pyjamas pyjs.org
It's a Python Compiler for web browsers. Write your client side in Python and Pyjamas will compile it into JavaScript.