How to create HTML pages using AMFPHP (on server) - html

I have AMFPHP installed on my server. I have a flash app that can call it's methods. I want to create some HTML (on server created) pages which will contain HTML code and results of AMFPHP functions. How to create such thing?

I did this a while back, but unfortunately don't have the code on this computer. However, here's a place to get you started:
http://www.flash-db.com/Tutorials/hello/flashamfphp.php
...and in general:
http://www.google.com/search?aq=0&oq=amfphp&sourceid=chrome&ie=UTF-8&q=amfphp+tutorial

Related

How to run a python script when a hyperlink is clicked from a webpage?

I have some code on my mac in the latest version of python idle 3, that collects certain data from a csv file that gets sent to myself and prints out the output in the terminal. I want to create a webpage that has a button or link that a user clicks and it runs the code and prints out the output of my program.
Eventually i want to be able to create a website with multiple links that can do the same operation.
Will i need to create an sql database? If so how?...
From the sound of it, you want to use a webpage as a user interface for your python script. Unfortunately without utilising a server-side language this is not possible.
Multiple options exist for reacting to a button press on the server side, with PHP being the most well known, but solutions using only python do exist, such as Flask.
If you're just after a local GUI for your script, simpler options exist within python such as Tk.
Actually you can expose this function using a webserver and then the webpage will call the server with the right url.
Since you are using python I will recommend to take a look at Flask http://flask.pocoo.org/ great micro framework to get you started.

Call a node.js function inside an html file

This is most likely a repeated question.
The closest I got to an answer was here: execute a Nodejs script from an html page?
Yet, I still can't understand.
So here's the situation:
I have an express server setup with the following files:
Express App
server.js
index.html
and right now I want the html folder to have a button, that calls a function set in the node.js file.
Tell me if more information is needed, thanks!
EDIT:
Im remaking the question to be more clear.
I am using an express server to present a website, that present a button saying " Power Off", I want this button to be able to execute an action on my server computer, that action being a terminal command to power it off.
I wanted to know how could I make said button, written in HTML, hosted on the server but presented to the client, to interact with the server.js file hosted on the server, which would have a function set to execute said command.
thanks!
You need to understand a little better how the client/server architecture of a web page works and where code actually runs and how the client and server communicate with one another.
You can't call a function directly on your node.js server from an HTML file. The HTML file is in the client's browser. The node server is your web server, far away from the client's browser on different computers. Though it may seem like your HTML is on your node.js server because it's in a directory on that server, that's only where it is stored. When the browser requests that page, your node.js server sends the HTML to the client's browser and it is rendered back in the client browser and that's where the Javascript in that page runs (in the client's browser, far away from your node.js server). This is a client-server architecture. The HTML page is running on the client. The node.js server is on your server - different computers.
If you want to communicate with the node.js server from the web page, then you use Javascript in the HTML page to make an Ajax call from the Javascript in the web page to the node.js server (An Ajax call is an http request). You then configure a route in the node.js server for that specific Ajax call and you can then write code in node.js to do whatever you want to happen when that Ajax call is received. It can carry out some operation on the server, it can retrieve data and return it to the client, etc... You can optionally send data with the Ajax call (either as query parameters for a GET request or as body data for a POST request) and then the server can optionally return data back to you (often as JSON, but it can be any format you like).
I'm not an expert with Node, but I think what's happening here is blurring the lines between server and client. Even though both use JavaScript, there's a distinction. NodeJS could easily be replaced with Ruby, PHP, Java, whatever-backend-language-you-like, and this distinction would apply in the same way it does when you use JavaScript on the server. There's no differerence.
Server-side code executes on the server. Client side code executes on the client (the browser). If you need to call a NodeJS function (assuming it has to interact with the other server side code such as databases etc) then you can send a request, either via AJAX or standard HTTP, to the a route on the server and call that function within the route.
On the other hand, if the function is generic enough and doesn't involve any specific Node code then you can simply add a script tag with your JavaScript file to the index.html page.
There is a difference between server and client. You cannot just call a function on a server from a client directly, there is more to just that. If you wanted to, you could do it by routing a path to wherever and making an HTTP request to that path, or even, using other protocols like WebSocket if you need to communicate both ways.

Creating a server / service client

I have been developing an app that has to access a DB and return data has charts in a web page. since it is to be added to another software i had to create it as a local server / servce, using self host web api, returning the data as json so i can read it in my html file and create the charts.
The server / service works, but my problem remains on the client. I don't know if i have to create another project for my html or if i just add a folder with my html and all css and javascript.
Basically when i run it i have to display my html file.
I have been looking the web for examples / solutions but i can't seem to find one that will help me, i've checked:
creating help pages with T4, but it includes all my css and js files in my html and when i want to change something i have to remove the include, debug and include it again;
create a web app but when i run it it creates me 2 servers, the one i've created and the web page server, although my web page will access it using angularjs, i can't have the second server;
I'm a little lost on how i will do it.
Can someone give me some help?
I'm using VS2010, self-host WebApi, console app, entity framework, angularjs, nvd3 and d3.
thk
If you have developed your project using MVC4 you can create view/controller related to report in webapi project.Point add html files to this view.This won't create 2 servers.

call nodejs scripts from html pages

I would like to call node.js scripts like i do with php, that is simply using their url.
I'm mainly a js programmer, so it would be wonderful for me to ditch out php totally and use node for the server side scripting.
But most of the tutorial i saw until now involved creating a server, etc...
I just want to call a script in the old way, like www.mysite.com/login.js instead of www.mysite.com/login.php
And once called the script should return or a page for rendering or simply json or other text for ajax calls.
Is it possible?
There's another possibility, similar to the CGI method mentioned above but using a module (https://github.com/samcday/node-fastcgi-application) in Node.js that supports FastCGI which would allow Apache to talk to it.
It actually blends both styles, so that the Node program is launched automatically by Apache but stays around as long as there are requests to process. You simply set up a rule to redirect the pages you want to a dispatch.njs script, which you have added with AddType in .htaccess as a Node script, which launches and then handles requests on the stdin and sends the results to stdout. But you still need the routing provided by express because it's only looking at HTTP_REQUEST_URI to determine what page you want.
Another option would be to setup Node listening on a certain port and proxy requests to it from Apache if they match a certain signature (like ends in .njs).
But most of the tutorial i saw until now involved creating a server, etc...
I just want to call a script in the old way, like www.mysite.com/login.js instead of www.mysite.com/login.php
That's how node.js works. You create a server. With PHP the first step of a tutorial is to install and setup apache (creating the server).
The equivelant of your question in PHP terms would be
Can I run PHP scripts without installing apache/nginx/other webserver
Which you can't (I believe recent or future version include a web server baked in, just like node.js !)
You need to install node.js, you need to tell node to run a web server
However you can use expressjs for a more streamlined and familiar setup. You can then just call express on the command line to scaffold your server out.
You still have to install node.js (and npm)
Node.js and PHP are two different things.
Node.js is an "event-driven I/O server-side JavaScript environment". When it functions, Javascript is not run as a scripting language, it is processed just like Ruby or Python. You start a server, and the code is run.
PHP, however, is run as a scripting language on a webserver, because the web server has a PHP processor module installed on it. Therefore, you can run PHP scripts directly by the .php extension, because the Apache server is configured to interpret .php files as scripts.
In other words, what you'd like to do is not possible without a large amount of hacky tricks, with node.js.
However, if you'd like to just use JavaScript instead of PHP, I'd check out JS-CGI, which allows you to use Javascript as a CGI extension.
You could use CGI. Something like this:
#!/usr/local/bin/node
var sys=require("sys");
sys.puts("Content-type: text/html\n");
sys.puts("Hello World!<br/>\n");
var argstr="";
for(var i in process.env){
argstr+=i+": " + process.env[i] + "<br/>\n";
}
sys.puts("args: "+ argstr +"<br/>\n");
Just like Perl/Python/../..

HTML5 Local Storage - Creating and writing to a json file?

We are building a web application using SVG & JS. The log file for this application needs to be created on the client side and then finally uploaded to the server once the project is ended.
As we donot wish to go near ActiveX controls, is it possible to achieve this with the new HTML5 'Local Storage'? Isnt that what 'Local Storage' is for anyways?
Is there a working example of this as well?
Many thanks,
Not really sure what you mean by this but there is something out there called jStorage.
It uses javascript and json to save data to the local database.