Play Framework JSON and HTTP Request [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am trying to perform a simple method that can handle JSON and HTTP request. Why is this? Because if in some point I decide to create, not only a Webapp also a Mobile APP, I can handle the request with JSON. (I donĀ“t know if this is the best way, if is not please let me know, what would you do?)
My problems is: to handle JSON and HTML in Play, I think that all the request and response need to be intercepted with JavaScript from the HTML side, because need to be parsed as a JSON object. But is there any way to do so , as if it were a simple HTML request?
What is the best way to create a back-end service that will work for a Mobile and WebApp?
Please let me know if you need more info. or something else and your opinion about how I am handling this.
Thanks in advance to all.

The best way is to create REST APIs with the JSON response so that you can integrate it with any UI app or mobile app. Playframework has given support for HTML too, but as per my opinion create a REST API
You can integrate this REST service to any UI app using any javascript framework.

Related

How to control Django with Javascript? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am building a web application with Django and I show the graphs in the website. The graphs are obtained from real time websites and is updated daily. I want to know how can I send graphs using matplotlib to template and add refresh option with javascript which will perform the web scraping script which I have written. The main question is which framework should I use? AJAX, Django REST, or what?
You're better off using a frontend framework and calling the backend for the data via JS. separating the front and backend is a more contemporary approach and has some advantages over doing it all in the backend.
From personal experience, it gets really messy mixing Python and JS in the same system.
Use Django as a Rest-ful backend, and try not to use AJAX in the frontend, then pick a frontend of your choice to deliver the web app.

Get a document from MongoDB and place in an html form [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Could you please suggest me what functionality I should use to get a document (containing a few lines of text) in a MongoDB collection and place it in an html form using JavaScript/Angular?
So, first I need to query the MongoDB from inside an angular script. Is there a simple way to do this, like for example in python, using pymongo to connect to a database?
And second I need to place the output of the query to an html form. Seems easy, but are there any bottlenecks I can face?
Sorry for silly question - this is my second day of web-development
Firstly for getting data from database you need to write server side code. You may write it in nodejs or any other language of your choice. Then in that code you have to make query to database and expose that data using REST apis. Then inside of your angularjs application you will have to consume that rest API and then show the data onto the html page.
Happy learning. Cheers!

How should I structure .net website to use a web api? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm starting a project that will use a search bar to hit a web api and return the results. There will be no writing to the web api.
My biggest struggle when creating a new project is how it should be laid out. I never know when i should create a DAO, do it all via javascript, put it in a controller, etc.
For developing something like a search engine or any web application. You would need following:
A frontend, which is your application's GUI in browser of user or mobile application.
A backend logic, this could be in any server side scripting language, in your case you would be writing server code in .net
Now, your backend must expose a search api, Eg. If I send a HTTP GET with a variable q, it should return search results matching the query.
Your frontend must have input-box and a button for allowing users to send this request.
This answer isn't complete, just a vague overview of how this problem can be approached, also this isn't the only solution.

Best Practices: Website and Database Integration [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What are the pros and cons of different methods of including data from a database on your webpage?
From my understanding I have two options. A html page, with JavaScript (or other browser language) that fetches and includes data. A php script (or other server based program) that builds and outputs an html page with the data already included. But how am I to made the decision between the two?
Always go for PHP when using a database. It is a more robust and proven technique.
Also PHP pages are protected by the server and nobody can see how the code works, they only see HTML output, whereas with Javascript anyone can see your code.
After all I don't know how JS supposed to interact with data, maybe store data in an XML page and then retrieve them, not sure. Why invent a wheel when you have PHP which is supposed to work with databases unlike JS which is designed mostly to be an improved front end functionality, unless its back end JS, but few people use JS that way.

How to write API for following web application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
My job is to write an API for my web application which is using another website authentication. I know very basic of javascript and PHP and HTML. I need some help to show me the path to write the API for this website.
Here is a link to the documentation of the website:
https://affinitylive.jira.com/wiki/display/APIS/Web+Applications
As it says, I must send this URL to get token->>>
https://hq.local.affinitylive.com/oauth2/v0/authorize?
scope=read(all)&
state=page_two&
redirect_uri=https://app.com/oauth_callback&
response_type=code&
client_id=34ad67fa2f#hq.local.affinitylive.com
and then after I got the token
POST /oauth2/v0/token HTTP/1.1
Host: hq.local.affinitylive.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic {client_id}:{client_secret}
code=frLA0s1m_D&
redirect_uri=https://app.com/oauth_callback&
grant_type=authorization_code
What I am not really sure and I love to learn is how this communication between my website and their website for authentication will be made. If the answer is wrong I wish to find a way to learn this more. Any guide or suggestion will be appreciated.
There are many methods to do this.
The below url will give you good information about them.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
And to achieve this, we can use javascript/php (example). In javascript we can make ajax calls to send the request. In php we can use curl to achieve the same.

Categories