Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Doh004
Apr 22, 2007

Mmmmm Donuts...
If you're making a CRUD app that also has corresponding tooling for users, you'll need the new and edit routes generally for those resources.

If you're just building an API, than yes, you'll be fine without them.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Doh004 posted:

If you're making a CRUD app that also has corresponding tooling for users, you'll need the new and edit routes generally for those resources.

If you're just building an API, than yes, you'll be fine without them.

Yes, but we're taking about Rest since that's the only place it makes sense to talk about alternative http methods.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Thermopyle posted:

Yes, but we're taking about Rest since that's the only place it makes sense to talk about alternative http methods.

Huh? I'm talking about REST too.

bigmandan
Sep 11, 2001

lol internet
College Slice
If you're building a website that consumes it's own REST API would not make sense to differentiate between API/user facing endpoints?

code:
//API endpoints: JSON, XML, other media types
GET /api/v1/products
POST /api/v1/products
GET /api/v1/products/id
PUT /api/v1/products/id
DELETE /api/v1/products/id

//Front end: HTML/AJAX
GET /products         // index, ajax GET to /api/v1/products
GET /products/create  // form, ajax POST to /api/v1/products
GET /products/id      // show, ajax GET to /api/v1/products/id
GET /products/id/edit //edit form, ajax PUT/PATCH to /api/v1/products/id  (depending on client/framework may need to fake with POST)
etc...  (or some sort of SPA instead of all these endpoints)

bigmandan fucked around with this message at 19:47 on Apr 4, 2018

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Doh004 posted:

Huh? I'm talking about REST too.

If you're just talking about REST then you don't need separate routes for new/edit....you just use the appropriate method. Which, BTW, is another reason to use appropriate methods. It cuts down on the number of routes you have to maintain.

If you're delivering user-side stuff to the browser then you of course need GET-able routes for new/edit.


edit: yeah that ^^

Doh004
Apr 22, 2007

Mmmmm Donuts...
I think we're all saying the same thing?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Doh004 posted:

I think we're all saying the same thing?

Yes, except for Nolgthorn who is I think is trying to argue that because the frontend might need GET-able update/edit routes that means something about how you should design your REST api?

Thermopyle fucked around with this message at 00:20 on Apr 5, 2018

Skandranon
Sep 6, 2008
fucking stupid, dont listen to me

Thermopyle posted:

Yes, except for Nolgthorn who is I think is trying to argue that because the frontend might need GET-able update/edit routes that means something about how you should design your REST api?

Because using Postman is hard and I want to exercise my entire API via the Chrome URL bar. Prove me wrong.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Skandranon posted:

Because using Postman is hard and I want to exercise my entire API via the Chrome URL bar. Prove me wrong.

I just clicked on a thing in Postman... and it was easy :smuggo:

spiritual bypass
Feb 19, 2008

Grimey Drawer
Just write a bunch of json files with payloads and use bash select to make a menu of them to execute with curl

Tei
Feb 19, 2011

I like REST, but using verbs other than GET or POST is like some naive student idea.

No until we get a battle royale where we drop the inventors of SOAP, OLE, REST and RDF in a tropical isle, with a assorted of deadly weapons. And we wait to see what one survive.

I believe in protocol darwinism, and I have no favorites.

bigmandan
Sep 11, 2001

lol internet
College Slice

Tei posted:

I like REST, but using verbs other than GET or POST is like some naive student idea.

No until we get a battle royale where we drop the inventors of SOAP, OLE, REST and RDF in a tropical isle, with a assorted of deadly weapons. And we wait to see what one survive.

I believe in protocol darwinism, and I have no favorites.

SOAP can die in a dumpster fire. gently caress SOAP.

Tei
Feb 19, 2011

bigmandan posted:

SOAP can die in a dumpster fire. gently caress SOAP.

I share the sentiment.

It seems to exist to solve some fortune 500 company problem, so I respect that. But for any other use is bloat to hell and just flat out don't work.

When you are a Java developer it probably work well to communicate with other Java developers using the same IDE, same version of the IDE, same version of Java.
Or if you are C#, to people with the same version of IDE, same version of C#. Fantastic tool in these environments.

The cynical person in me thinks that maybe this is the feature: create vendor lock in, so you are forced to use Java if you want to talk with Java. But Microsoft or Oracle would not do vendor lock-in. Thats would be like wrong.

Careful Drums
Oct 30, 2007

by FactsAreUseless

Tei posted:

I share the sentiment.

It seems to exist to solve some fortune 500 company problem, so I respect that.


I'm pretty sure the problem is "what technology can I choose that will assuredly not get me fired?"

Capri Sun Tzu
Oct 24, 2017

by Reene

Tei posted:

I like REST, but using verbs other than GET or POST is like some naive student idea.
I kind of agree, this is one of those "best practice" things that just doesn't matter. There's not a strong argument against a GET-only API and a mild one for it. You can stick a get request in any old hyperlink and lets face it, if you're using someone's API you're going to have to study the docs anyway.

bigmandan
Sep 11, 2001

lol internet
College Slice
HATEOAS or bust :colbert:

Funking Giblet
Jun 28, 2004

Jiglightful!
*scans to see use of patch*

Pfft, Restful...

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Tei posted:

I like REST,

No one should like REST. Its kind of icky!


With REST as with with most design patterns and standards, the idea isn't whether it does it in the absolute technically best way possible. The benefit arises from the standardization across time, developers, projects, and organizations. Also, most of the time with such patterns it's so easy to discount the relatively minor developer time and effort savings and disregard the large amount of time and effort savings across all developers. The tragedy of the commons as they say.

If there was a standard for GET-based APIs where every time you came across one the "new" url was product/new/ then that'd be cool (as well as being almost exactly like REST...just rearranging the characters in the raw HTTP request). But that's not the case...GET-based APIs are the wild west. Other options and standards are basically fine too, it's just that on today's web REST is probably the most ubiquitous. In other words, my argument isn't for REST it's for any sort of not-horrible standard.

I mean, it's not like I'm going to slit my wrists if I see a GET API again. As I mention above, for the developer it's often a miniscule time/effort thing.

However, if you're a developer and you don't use the millions of options available to you other than putting an URL in the address bar to explore an API I don't really know if your problem is REST. Usually, tools like Postman are even better than dropping an URL into the address bar anyway.

Thermopyle fucked around with this message at 18:51 on Apr 5, 2018

Tei
Feb 19, 2011

I would not use GET to create a new anything. GET is supposed to be cache because you are downloading a resource from a location. POST /products/new do make sense to me.

Tei fucked around with this message at 18:57 on Apr 5, 2018

porksmash
Sep 30, 2008
What does a POST to /products do in that case if POSTing to /products/new is how you create objects?

Tei
Feb 19, 2011

porksmash posted:

What does a POST to /products do in that case if POSTing to /products/new is how you create objects?

I would just not use the verbs semantically, but based on his properties. GET is used to download existing files, so each time I visit a URL, I get the same stream of bytes. And POST is to send data and get random bytes back. POST to /products make sense if the list of products can change over time.

I am a simple men, possible dumb, so ignore my opinions.

Boosh!
Apr 12, 2002
Oven Wrangler
Random jQuery question:

I'm dynamically appending divs to my page and need to access them after they are loaded. StackOverflow tells me to use .on which works but only if it's tied to an event:

code:
$('.container').one('mouseover', '#newId', function(){
                    $(this).find('button').text('saved');
});
I would just like to do something without having to wait for an event to be triggered (mouseover doesn't fire if I'm using my wheel).

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Boosh! posted:

Random jQuery question:

I'm dynamically appending divs to my page and need to access them after they are loaded. StackOverflow tells me to use .on which works but only if it's tied to an event:

code:
$('.container').one('mouseover', '#newId', function(){
                    $(this).find('button').text('saved');
});
I would just like to do something without having to wait for an event to be triggered (mouseover doesn't fire if I'm using my wheel).

You can store a reference to each div you create when you create it, and then do whatever you like whenever you like.

Boosh!
Apr 12, 2002
Oven Wrangler
Thanks Lumpy. I should’ve noted it was created from an infinite scroll plugin that grabs a html content from existing pages and appends it to the roll. Looks like there’s a callback so I will tinker with that.

huhu
Feb 24, 2006
I'm trying to read up on how a request is typically processed on the backend. All the articles I'm finding basically just have "... And then the server processes the request and generates a response...". I have worked a lot in the backend but would like a thorough explanation of the entire process. Any good articles/videos I should checkout?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

huhu posted:

I'm trying to read up on how a request is typically processed on the backend. All the articles I'm finding basically just have "... And then the server processes the request and generates a response...". I have worked a lot in the backend but would like a thorough explanation of the entire process. Any good articles/videos I should checkout?

I can't recommend anything specific, but i know I've seen stuff in the past in relation to how python works with WSGI. Try googling stuff like "django wsgi request response how it works".

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug
Could use a second set of eyes. Created a react server rendering app with express and Webpack 4. I'm getting build errors when it imports the semantic-ui css file. The errors are because its failing to resolve resources like fonts/images being @import'ed. I setup url-loader to handle this but it's still failing and I'm really baffled. I've never had trouble setting this kind of thing up until my first foray into server rendering so I could be missing some nuances.

Repo: https://bitbucket.org/hhorne/minssr

Example errors:

code:
ERROR in ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css
Module not found: Error: Can't resolve 'themes/default/assets/fonts/brand-icons.eot' in 'C:\src\minssr\node_modules\semantic-ui-css'
    @ ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css 7:424086-424140 7:424166-424220
    @ ./node_modules/semantic-ui-css/semantic.min.css
    @ ./src/components/root.js
    @ ./src/components/index.js
    @ ./src/routes.js
    @ ./src/client.js
    @ multi @babel/polyfill webpack-hot-middleware/client ./src/client

ERROR in ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css
Module not found: Error: Can't resolve 'themes/default/assets/fonts/brand-icons.svg' in 'C:\src\minssr\node_modules\semantic-ui-css'
    @ ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css 7:424558-424612
    @ ./node_modules/semantic-ui-css/semantic.min.css
    @ ./src/components/root.js
    @ ./src/components/index.js
    @ ./src/routes.js
    @ ./src/client.js
    @ multi @babel/polyfill webpack-hot-middleware/client ./src/client

ERROR in ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css
Module not found: Error: Can't resolve 'themes/default/assets/fonts/brand-icons.ttf' in 'C:\src\minssr\node_modules\semantic-ui-css'
    @ ./node_modules/css-loader??ref--5-1!./node_modules/semantic-ui-css/semantic.min.css 7:424463-424517
    @ ./node_modules/semantic-ui-css/semantic.min.css
    @ ./src/components/root.js
    @ ./src/components/index.js
    @ ./src/routes.js
    @ ./src/client.js
    @ multi @babel/polyfill webpack-hot-middleware/client ./src/client
Edit: The trick was in the webpack config for the server, the externals setting needed to be changed to "externals: [nodeExternals({ whitelist: /\.css$/ })]"

Dr. Poz fucked around with this message at 22:23 on Apr 9, 2018

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.
I once found a really great modern article discussing primary and secondary buttons, specifically secondary buttons and when to use ghost buttons vs when to use colored link.

But for the life of me I cannot find it. I know it was popular because I got it from either here or a suggestion but just cannot find it...

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun
As a person who isn't well-versed in frontend stuff, but who wants to build an application using new technologies, are there any resources you can recommend? I know Javascript, but I am not well-versed in the world outside plain ol' vanilla JS and JQuery. I'm also basically only familiar with Bootstrap and would like to step outside that world. I've played with React a bit a few years back, but nothing serious.

Basically, what should a backend developer like myself do to make their full stack skills more full stacky?

This is a side project, so even if it's a bit esoteric I'm cool -- the backend is being written in loving Haskell (though I'm oscillating between that and F# or Ocaml), I can deal with some weirdness on the frontend.

Ghost of Reagan Past fucked around with this message at 02:16 on Apr 12, 2018

Murrah
Mar 22, 2015

Kind of a dumb question but basically:

I have only been exposed to Python in a data science context, where it was used with some libraries in a Jupyter notebook.

Ive never really seen it in action for web development for back end stuff.

I know there is this wide vast internet out there but if someone maybe had a suggestion or link to a resource or simple example of it running an app or otherwise I would appreciate it.



Ghost of Reagan Past posted:

As a person who isn't well-versed in frontend stuff, but who wants to build an application using new technologies, are there any resources you can recommend? I know Javascript, but I am not well-versed in the world outside plain ol' vanilla JS and JQuery. I'm also basically only familiar with Bootstrap and would like to step outside that world. I've played with React a bit a few years back, but nothing serious.

Basically, what should a backend developer like myself do to make their full stack skills more full stacky?

This is a side project, so even if it's a bit esoteric I'm cool -- the backend is being written in loving Haskell (though I'm oscillating between that and F# or Ocaml), I can deal with some weirdness on the frontend.

I mean unless you have an aversion to it I would suggest picking React back up again and working on Javascript ES6 stuff alongside that.

Murrah fucked around with this message at 03:19 on Apr 12, 2018

Capri Sun Tzu
Oct 24, 2017

by Reene

Ghost of Reagan Past posted:

As a person who isn't well-versed in frontend stuff, but who wants to build an application using new technologies, are there any resources you can recommend? I know Javascript, but I am not well-versed in the world outside plain ol' vanilla JS and JQuery. I'm also basically only familiar with Bootstrap and would like to step outside that world. I've played with React a bit a few years back, but nothing serious.

Basically, what should a backend developer like myself do to make their full stack skills more full stacky?

This is a side project, so even if it's a bit esoteric I'm cool -- the backend is being written in loving Haskell (though I'm oscillating between that and F# or Ocaml), I can deal with some weirdness on the frontend.
Angular/React/Vue are the flavors of the month, but check out Knockout.js if you want something much simpler to introduce you to modern web apps.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Capri Sun Tzu posted:

Angular/React/Vue are the flavors of the month, but check out Knockout.js if you want something much simpler to introduce you to modern web apps.

Angular (original flavor) and React are both multiple years old at this point, so calling them flavors of the month is kinda weird, but that's a good idea! Knockout is fairly simple and pretty nice. Not terribly performant, but that's OK most of the time.

Capri Sun Tzu
Oct 24, 2017

by Reene

Munkeymon posted:

Angular (original flavor) and React are both multiple years old at this point, so calling them flavors of the month is kinda weird, but that's a good idea! Knockout is fairly simple and pretty nice. Not terribly performant, but that's OK most of the time.
You're right, I must be getting old. I like to recommend knockout as an intro to frontend frameworks because it's very focused and unopinionated. To get started with angular, etc, you have to invest learning the "angular" way of doing things.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Capri Sun Tzu posted:

You're right, I must be getting old.

:same::respek:

bigmandan
Sep 11, 2001

lol internet
College Slice
I use Vue.js a lot now and quite enjoy it. When I was first getting started with it, I found it pretty easy to get up and running. There's a lot more you can get into with it (vuex for example) but I found the learning curve for it to be fairly reasonable.

Knifegrab
Jul 30, 2014

Gadzooks! I'm terrified of this little child who is going to stab me with a knife. I must wrest the knife away from his control and therefore gain the upperhand.

bigmandan posted:

I use Vue.js a lot now and quite enjoy it. When I was first getting started with it, I found it pretty easy to get up and running. There's a lot more you can get into with it (vuex for example) but I found the learning curve for it to be fairly reasonable.

I am two weeks into vue professionally and I cannot agree with this more.

prom candy
Dec 16, 2005

Only I may dance
edit: nvm

prom candy fucked around with this message at 19:36 on Apr 13, 2018

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Murrah posted:

Kind of a dumb question but basically:

I have only been exposed to Python in a data science context, where it was used with some libraries in a Jupyter notebook.

Ive never really seen it in action for web development for back end stuff.

I know there is this wide vast internet out there but if someone maybe had a suggestion or link to a resource or simple example of it running an app or otherwise I would appreciate it.


I have this same question and I'll give an example.

I can make a python application take some inputs do stuff and output a pretty graph.

I want to take a set of inputs as text and images through my website pass it through my python application and spit out this graph to the user. How?

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

CarForumPoster posted:

I have this same question and I'll give an example.

I can make a python application take some inputs do stuff and output a pretty graph.

I want to take a set of inputs as text and images through my website pass it through my python application and spit out this graph to the user. How?

Look into Flask, it basically takes care of all the web-specific overhead without doing too much other stuff on its own. All you'll need to do is figure out how the information is passed in through Flask, and then instead of saving the result as a file (or, you can save a temporary file on the server), you'll use a Flask response to return the graph as image data to the client. Apart from the input and output steps, and making sure Flask is set up properly, your application should work exactly the same as it currently does.

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

PT6A posted:

Look into Flask, it basically takes care of all the web-specific overhead without doing too much other stuff on its own. All you'll need to do is figure out how the information is passed in through Flask, and then instead of saving the result as a file (or, you can save a temporary file on the server), you'll use a Flask response to return the graph as image data to the client. Apart from the input and output steps, and making sure Flask is set up properly, your application should work exactly the same as it currently does.

Would this be the same if my web framework of choice is django?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply