Using javascript to pass web forms values to python script - javascript

What I have done:
1- Created a web form using HTML and javascript to create a SSL certificate that can create dynamic certificates.
2- Successfully parsed through an existing certificate and passed the required values to the web form.
3- I am using the HTML+javascript inside the python script itself and appending the parsed certificate values to the javascript before displaying it.
What I need to do:
1-Take values from the web form, assign those to particular variables and pass those variables to a python script, that can create a CSR using those and sign it using a dummy key.
So, basically, I want to call a python script on a click of a button that can take web form values and create a certificate.
P.S. PHP isn't an option for me, as the server I am working on doesn't support it.
Can someone guide me in the right direction as for how to proceed? Any examples or study material? Or should I start working with Flask?

Django is a good option to create applications using python. You can start an application, and embed your code in template and write a view to handle requests and responses.

Related

Creating and editing .text file from javascript

I am making a web site that makes a record of the person who visit it
I have created a html form page that requests the name from the user
But I am unable to figure out how to keep record of it,maybe something like using making a text file and having javascript add names to it,but I am not sure how to do it
I am using Google drive and drv.tw to upload the site so I can't use any server side scripting language
Native JavaScript has not access to user's file system. But Node.js has, try this one if u can. In native JS you can use something like localStorage. But this solution only for your task, do not use this for production...

How can i connect JavaScript to a SQL server?

I work as an intern in a manufacturing company that designed a HTML web page run by JavaScript that is supposed to show real time statistics of the machine lines.
To do this it must connect to a SQL server in real time to obtain the data that it needs to display charts and reports.
I have good knowledge of other programming languages but I'm a rookie at JavaScript and I would like to know the safest way to do this, since the database contains sensitive data.
Can this be done?
You need some sort of middleman to connect to the database. Since you want to do this with JavaScript, I suggest you checkout NodeJS . You can then build a simple API that when consumed it will return the data required. One benefit of building an API is you will be able to consume it from the website that is already built without having to make any changes in the back end. You can simply use fetch the data from the front end using JavaScript.
Don't do this directly with Javascript in your HTML file in client-side(It is not secure).
Do this with any language that you know on the server side and read those data using ajax and display them in your HTML file.

Code needed for form to talk to phpmyadmin backend

I am creating a search form in wordpress using html and javascript. The form has dropdown menus which will have preselected items. These items come from the phpmyadmin(wordpress backend database). I'm having trouble writing the php code so the form talks to phpmyadmin backend. Does anyone have code for this?
John is right on that. PHP MyAdmin is a web based utility for accessing MySQL similar to WordPress which is a CMS. You will need to make queries to the backend database either directly(Not Advised) or to a web server. Wordpress has support for plugin databases built right in. Just gotta do a couple things.
Per The WordPress Site
Write a PHP function that creates the table.
Ensure that WordPress calls the function when the plugin is activated.
Create an upgrade function, if a new version of your plugin needs to have a different table structure.
WordPress - Creating Tables with Plugins
If you insist on writing it yourself you will need to setup a web server like Apache or nginx to listen to request and execute your PHP scripts.
PHP 5 Form Handling
PHP Connect to MySQL
and if you want to go dynamic
Ajax and JS, but you may want to use PostMan for testing.

How can I use session specific data files in javascript

I am creating a web application using Ruby Sinatra. However, I think this question is more related to html/javascript.
In the front end I am using d3.js for some pages. I want to create and use data files based on user input. So for each user session I want to create a data file for that session.
I think I can create the custom html/javascript for each request.
Is there any other way to do this, such as passing the file name to the javascript?
You can use sessionStorage (some examples is here http://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/)

Can I use PHP SDK and JAVASCRIPT SDK at the same time?

I have a php program/app which asks for input, generate an image and post th image link to user's timeline (processor.php). I used PHP SDK in posting to timeline since I am more familiar with PHP. Now, in my gallery.php, i want to show like buttons for each generated image. I am aware that i have no option but use JS SDK in making button. but is it fine if i use two different SDK's in a single app?
processor.php - PHP SDK
gallerry.php - JS SDK
thanks for your answer! I would love to try your suggetions too
There shouldn't be any problem using PHP and JS in the same application, quite a common use case. You would normally use PHP to create the Web Application structure, handle backend logic, and then use JS to handle UI events.
There's nothing special about combining the two, just create the Web page with JS as normal for the view, and use PHP to build it.
Hope this helps.
Yes, there is no problem, the two APIs are designed to work together. The PHP API is usually used to created the backend logic (for example OAuth implementation, posting and getting data, etc) and the JS API to handle user iniated events.
Also see this: https://stackoverflow.com/a/6728092/1107118 on how to handle login state. Normally the JS API is used for logging in too, and then with the PHP API you take the access token and do the backend actions.

Categories

Resources