#web-development
2 messages Β· Page 11 of 1
Either you write it in an html and import it from the template, or in your base html, or you can register a python function if you're feeling brave
Basically write a macro with two parameters, one is your classes and one is the form field object. Then you write your html and inside the label tag {{ field }}. Bam, you have a reusable thing that does what you need
(I'll be really sorry though if there is a way to nest "expressions" the way you wanted. But I doubt it)
Can somebody help me figure out how to get AOS(animate on scroll) working with my flask application?
I followed it's documentation, and looked on stack overflow, and can't find out how to make it work. I tried importing how the docs say, I verified jquery is working, but I can't figure out how/where I'm supposed to AOS.init() because AOS is always undefined
Also verified that flask is seeing my aos.js
https://github.com/michalsnik/aos
for reference ^
GitHub
michalsnik/aos
aos - Animate on scroll library
I followed the installation instructions provided at the link above
my error:
Is the <script src="https://.../aos.js "> on the page?
yes
i followed the exact instructions provided and the initialization is my only problem
and i used web dev tools to verify that my scripts are all on the page
I'm confused...
Hey guys, quick question about Django. I'm making an app for a school and I'm wondering about how to deal with different types of users
Current I've got models for teachers and for students (which have a foreign key relationship to the generic user model)
But I'm wondering if I should just use different groups for both
Models with foreign keys to the settings.AUTH_USER_MODEL are generally the way to go about this, as far as I'm aware
What do you mean with "different groups", though?
If you want to deal with permissions, you probably want to create Teacher and Student groups through a data migration
Yeah it'd be with permissions, but also the teacher and student models have relations to other models (e. g. Assignments, classes, etc)
By groups I mean the option to create groups through the Django admin
So with AUTH_USER_MODEL, would I create the two different models (teacher and student) and add both to settings?
I'd like it to have 3 tiers of permissions, admin > teacher > student
(sorry, still pretty new to this)
if the idea behind the custom models is purely permissions and you don't want to have any custom fields based on hierarchy, then you'd only use groups - but if as you said they have relations to other models, then having custom models is obviously the way to go. As for teacher and student permission hierarchy, groups would be the correct way to do it, but since you already have the student and teacher models, I'm not sure if it would be necessary - i'd use groups regardless since they integrate with django's permission system. You can use a signal or override save() in the teacher and student model to automatically add the student or teacher to the respective group on creation
For admins, I don't think you need a custom group, but it depends on what you mean by "admin". If that means logging in to the django admin, use User.is_staff: https://docs.djangoproject.com/en/2.0/ref/contrib/auth/#django.contrib.auth.models.User.is_staff
you can then give that user the appropriate permissions on the admin page
I could set it to all users that are teachers right? Or would I have to go through and select each individual user
What might be worth noting is that Django 2.1 will add a view_x permission in addition to the regular add_x, change_x and delete_x permissions, but I think it still doesn't support object-level permissions (such as teacher x can edit course z but not course y), for that you might want to look into guardian: https://github.com/django-guardian/django-guardian
You can just add it on creation time
Ah OK cool
you can check out this code I wrote for a more involved example using signals: https://github.com/strinking/site/blob/master/home/signals.py#L12
also, to (sorry, still pretty new to this), don't worry about it, Django is quite the huge framework and it takes some time to get into
Awesome, thanks for the help!
π
hmm can i somehow do a form that shows more options depending on what checkboxes are checked
on flask and wtforms
and bootstrap
generally, questions about "can i" can generally be answered with "computers can do anything if you work at it hard enough", and i really like referencing that
dynamically displaying form fields is probably the easier part, but I would assume that complicates validation a bit
its written in flask and the forms by flask-wtforms, and it seems like it's not passing the validation phase of UpdateAccountForm
no errors or anything
just doesn't update
the relevant files are routes.py and forms.py
how can i make something like this:
Skill name
[-----------]
add another... [SUBMIT]
and when clicking add another it would turn to
Skill name
[-----------]
Skill name
[-----------]
add another... [SUBMIT]
@hearty birch Is this AQA?
Ah
how can i read field values when i dont know the field's id or name, on flask with wtforms
i have a form where user can press a button to add a new field for new language and i want to read all the fields that user has added with the button
Would the form not return a dictionary mapping the form name to value
If so just iterate over that
good point
Hello! I have a question to Django Masters :D. So i have my Book/Authors Wiki web app and in my Book model i have a CHOICES. It is a book types there (Historical, Drama, Horror etc). And i need to have another view, book_type_list view and there a list of my choices. But i don't know how to display all choices from my model. Anyone know how to do it? Sorry for my english π
It's been a couple years since I touched Django, but for starters what does your Book model look like?
It's fine, I played the witcher
I create a new template (book_types_list) and i would like to have there all values from book_types
but i don't know how to create a view like this to display all types
You can pass Book.CHOICES (as a class attribute) as a parameter to your render template function
From inside the template you should be able to access it
I'm not on my pc so I can't check my old Django project right now but I remember it was similar to flask π
Okay, so i read a documentation and i read something about get_FOO _display method
i create a view like this
but when i take a 'book_types' in my template
a have a bug
"not enough values to unpack (expected at least 1, got 0"
It is a book_types = Book.get_book_types_display()
Lemme check the docs
Okay
Based on the docs
It should be get_BOOK_TYPES_display
Watch the case
I don't know if case is relevant for that function implementation tho
I try to take a BOOK_TYPES but then i have another error - type object 'Book' has no attribute 'get_BOOK_TYPES_display'
;<
Nvm it's not. But also this isn't the function you want, I believe
You want to retrieve the entire content of BOOK_CHOICES right?
Yes
In the context, pass Book.BOOK_TYPES
The _display function does something different, it gives you the "long name" for the choice of the current record
Okay so at the first
Delete book_types value from my view
and just add a Book.BOOK_CHOICES':Book.BOOK_CHOICES to my context
?
('Book.BOOK_CHOICES':Book.BOOK_CHOICES)
Sorry it's book types, I forgot what's it called in your module
Just pass {"book_types": Book.BOOK_TYPES} as context to the render function
Then inside the template you can access the collection by referring to book_types
but with zeroes?
I mean, look at your model definition π
It's hard to help people on mobile, can't open tabs haha
aff xD
type object 'Book' has no attribute 'BOOK_CHOICES'
Why is it B00K_CHOICES instead of BOOK_CHOICES in the hastebin linked earlier?
It's Book.the_same_damn_attribute_in_your_class_definition π
Sorry for all the confusion
No problem, everything work so very good π
tl;dr the function you were using didn't do what you thought it did π
Dunno if there's any other helper to get the choices, but passing the class attribute is simple enough.
OKay, so another question xD
i have something like this now
if i would like to have only the names of types (not (1 'biografia) but Biografia)
It's a way to do it?
:x
You should be able to do that from your template. What do you have currently?
i have something like this in this moment
i delete {{book.book_choices }} becouse That it is unnecessary
because *
javascript:
fetch(server, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(someData)
});
Why I am not seeing the data in request.POST (using django) ?
@native tide You probably want to do something like book_type[1] in order to extract the correct value from the tuple.
yes, exactly
Another question
I have a book_types list and i would like to take a new view (if i click to type then i move in to book list with this book_type) , what is a simple way to do it?
hey guys, can anybody tell me why reddit uses blob: urls for <video> instead of a normal file? There is normal direct links actually specified outside of the <video> element, so what's the point, what are the advantages of layering it this way? Are they just trying to hide save-video/copy-video-url browser functionality?
seΓ±ores, por favor
in <head> <meta name="description" content="Site description here">
either that, or by using OGP tags
see the meta tags on that page
How would I Go on and Create a user signup in django? Do I just create a new model and set the password field equal to a certain type of Field or do I have to use some build in function and use the existing users table?
so I have a bit of a weird problem
print(secure_filename(file.filename))
if not NotExe(file.read()):
return abort(415)
filename = hashlib.md5(file.read()).hexdigest()
print(os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)))
if not os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
just storing exe files with there names as md5 hashes, when all of a suddent
if not os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
starts returning true
def NotExe(MyData):
meme = None
print("NotExe Check")
try:
meme = pefile.PE(data = MyData)
except:
return False
finally:
pass
if meme is not None:
if (meme.FILE_HEADER.Characteristics & 0x2000) == 1:
return False
return True
I figured out why, I'm using file.read() so I have to close it
it is a spooledTemporaryFile
that contains the data
nope I completey figured it out
hmm, im returning a bunch of checkboxes to flask and wtforms, im wondering what would be the best way to handle adding a line to database based on what boxes are checked?
i dont want to have a large block of if statements
hi guys, was wondering how i would implement some sort of discord login with Flask
similar to how pydis.com does it
Does anyone have a link to the original code for Class based views, like a detailview
Yo i'm planning to learn things about django, what's the advantage of it besides laravel CI etc ?
Its nicer than flask because it has a bunch of stuff already attached to it
so for stuff you can do like from django import login (but the actual name of it i cant remember) and boom you got authentication
(someone correct me if i'm wrong but thats my understanding)
@hearty birch pydis is still open source you could just read what they did
that is true, why did I not think of that π§ thanks
flask is also mean to be a 'micro-framework', ie one with very few dependencies
for most things, you'll need to install a lot of third party packages and such
"a lot" is an over exaggeration
depends how you define 'a lot'
also changes with the complexity of the project
either way i like flask and django for their own purposes and for different reasons
In trying to link a button to another page and every time I press the button I get method not allowed, I have my method set to get and post, https://gist.github.com/RAFFSIMOMS/fd0957357fb9ce82f7599b56d49e8182
What would you guys recommend for learning about user logins and authentication within flask?
I mean I'm most of the time I only use flask-login and the sqlalchemy flask module too
So if a lot is two
http://prntscr.com/k9tzmj this is my site
files:
http://prntscr.com/k9tzrj
So I guess the issue is the lack of styling
Best thing to do is for you to bring up the console
Hit F12, console tab, reload the page
it'll show any errors there
it is a template...
your point?
is that you didn't write the tags, yes
But like, if you're going to be doing web work
you shouldn't be using someone else's template
do you know HTML?
well
You would still need HTML
basic html?
You should be relatively proficient with HTML before you build a site with it
htmldog is a resource I see mentioned a lot here
i like w3schools xddddddd
i know the basics
not off by heart
but iknow the basics
w3schools is fine if you already know HTML
if you don't, use htmldog or https://developer.mozilla.org/en-US/
should i install flask or django on my vps?
The webapp framework you use is up to you
Flask has a fairly gentle learning curve for beginners
Okay
How do I upgrade my python ver?
im on 3.5 apperently
is there a command to go to 3.6
Depends on what OS you're running
You're on windows iirc so you just uninstall the old one and install the new one
Then use your system's package manager
If it doesn't have the newer version, stick with what you have
I think on debian it's sudo apt-get update && sudo apt-get upgrade
thats doing something
that'll update all of your packages
root@KCWS:/var/www/main# python3.6
-bash: python3.6: command not found
it didnt update py
root@KCWS:/var/www/main# python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
Wasn't Debian's latest version of python 3.5?
3.6 is only in the testing repos
Because for whatever reason the Debian Devs consider it unstable
So you either setup the testing apt repos or compile from source
bot.tags.get ask
Asking good questions will yield a much higher chance of a quick response:
β’ Don't ask to ask your question, just go ahead and tell us your problem.
β’ Try to solve the problem on your own first, we're not going to write code for you.
β’ Show us the code you've tried and any errors or unexpected results it's giving
β’ Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
did you open the port?
Anyone know why my html file is displaying as html code?
Did you do what the guys in the comment said?
@queen fiber what jquery do you need help with
Yes I did open the port @brave mantle
well, assuming it's running, the firewall isn't blocking it, and you're connecting to the right host, it should work.
But that isn't timed out
That's connection reset
I'm pretty sure you just haven't allowed the connection through iptables
@quartz maple you can check if its listening on the port with sudo lsof -i :FLASK_PORT where FLASK_PORT is the port you configured it with
It doesnt return anything @meager anchor
Can anyone help?
is css & html discussion allowed here? or only flask and django stuff
I'll take a look in a sec
Do you know Flask?
ah
do i need to run a virtualenv?
its running on a vps
maybe you messed up a flask function somewhere and it's not returning anything?
i mean i copied it from the tutorial
is it throwing any errors in the terminal?
What are you hosting this on?
Okay, and iptables -L gives you what?
I need the whole thing.
So perhaps use our paste service instead of a screenshot.
Looks like you're using PuTTY so just selecting the text should copy it
Ah, of course, ufw
fix?
Try ufw allow 5000
I have done that
Skipping adding existing rule
Skipping adding existing rule (v6)
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "<h1 style='color:blue'>Hello There!</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
Ye
ye
Click it to turn off the cloudflare proxy
Done
Then try again in about 10 minutes
Cloudflare will only proxy standard Web ports for you, that's 80 and 443
Note
The IP address on your domain will point to the actual server IP now instead of cloudflare
o
You should secure your SSH server with either a really strong password, fail2ban, or disabling password logins and using SSH keys
it has a strong password
I highly recommend fail2ban
Yeah, it's very useful
It basically blocks IPs in the firewall for a while if they get the password wrong too many times
even on my private vps which only hosts a discord bot, fail2ban bans 100s of ips daily
yea
alright time to ask my css question
I have the following div (eu cookie notice):
yea I want there to be no empty space
when I set the padding (or margin) to 0, the div shrinks
setting margin & padding on the image tag does nothing
this is what happens when I set the margin to 0 on the div
Isn't that what you wanted?
nah, the div shrunk
You could set a min-height on the div then
or set padding on another element inside the div
@brave mantle ey bro
You'd probably be better off applying the padding to a div containing the text/button
rather than setting a min-height
alright
Sup @quartz maple
ImportError: No module named 'wsgi'
You don't really need uwsgi for that
tbh you probably don't want uwsgi either
you probably want gunicorn
@brave mantle that worked! thanks
how do i do it with gunicorn
Small alert: As of today (the 24th), Chrome/Chromium will display all non-HTTPs sites as insecure.
@quartz maple Error's pretty clear
No module named 'myproject'
You probably forgot to tell gunicorn where that folder is located
the website I'm working for is still http... 
Did you read the error?
hang on
why did you call that file wsgi?
that's a thing you need to have not done
name it app or something
and then use app:app
You didn't include the command you ran
gunicorn --bind 0.0.0.0:5000 app:app
and the folder you're in?
(main) root@KCWS:/var/www/main/site/main#
actually, that's a problem with your own code
File "/var/www/main/site/main/app.py", line 1, in <module>
from site import app
ImportError: cannot import name 'app'
Have you covered Python's basics in a tutorial or something?
yes but got nothing to do with this,,,,,,
idk what import app is?
from site import app
didn't you write it?
Im following a tutorial
what are those bin/include/lib folders?
Yeah, but if you don't know what the syntax means, you need something lower-level
idk what its reading tho..
well it's not, because site is a built-in python module
part of the standard library
which definitely doesn't have app in it
Okay, but then site.py is not in the main folder
so why are you trying to run some other file?
Okay @brave mantle site.py is what flask uses to run and return a webpage.
The other one is the virtual environment
In main
Hello. I have a web app in django - database with books and authors. I would like to create a Voting view. Somebody know what is the best way to do it?
Hey \o/ what do you think of cookiecutter django? would you recommend it?
@native tide We cant write code for u
But
I would imagine that the user clicks a button on a book or something and then it records the vote to a db
And adds 1 vote to a field in the db
and IntegerField
The Django docs have a beginner tutorial that goes through the steps to make a polling app https://docs.djangoproject.com/en/2.0/intro/tutorial01/
Since we are in a flask discussion , i need some help with caching search quries or finding a way to make them faster
currently using flask-msearch
Anyone know how I get checkboxes in flask? I wanna do a calculation on all the selected files, in flask app builder
@grand badge Thanks, in this moment I using a django-stars-rating from github in my project. It work's fine π
@brave mantle
β site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: ena
Active: failed (Result: exit-code) since Wed 2018-07-25 22:05:48 UTC; 23s ago
Main PID: 24012 (code=exited, status=210/CHROOT)
Jul 25 22:05:48 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site
Jul 25 22:05:48 KCWS systemd[1]: site.service: Main process exited, code=exited,
Jul 25 22:05:48 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
lines 1-9/9 (END)...skipping...
β site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-07-25 22:05:48 UTC; 23s ago
Main PID: 24012 (code=exited, status=210/CHROOT)
Jul 25 22:05:48 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/CHROOT
Jul 25 22:05:48 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
I dunno why you're mentioning me specifically
Β―_(γ)_/Β―
plenty of other people around here
but anyway, go read the logs
they'll be in /var/log somewhere
i mention you as ur the only one who helps
which log?
How do i do this:
Create and bind to a Unix socket file, myproject.sock, within our project directory. We'll set an umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access
Anyone with Dash/Flask experience got a few minutes?
helllo lads
can someone help with reddit css?
i want to remove this flair box in the sidebar: specifically this one
i tried to inspect element that part, but nothing shows up
does that mean it can't be removed by reddit css
With python
How can I make online multiplayer
Heard of websockets and sockets not sure how to thoufh
Thoufh
Though
Any help please
are you referring to online multiplayer for browser games or for desktop apps?
Desktop
usually you would write the client side aka the desktop app in a language actually suited to gaming
like c++ c# etc
and if you are using a prebuild engine, which you would usually do it is extremly likely this engine already has support for the server side built in
so you would write the server side in that lang too
the same way you would do it with any lang
how can you do it is such a general question
It's a 3d game where there's boxes on a flat plane
If someone starts it creates a new box for them they can control
And it's online multiplayer like that so they can see each other controlling the boxes
if you dont want to fight with the pain of plain sockets (trust me you dont) you'd use the twisted framework for python
supports both server and client side
twisted has async support
There's no advantage to using twisted though
ive seen twisted listed as a requirement for some backend jobs in game dev
Β―_(γ)_/Β―
so you would use some sort of async framework
your decision i guess
anyway once youve picked your framework
you would have to build some sort of synchronization mechanism
so the server always contains the state of a game and the clients can read from it and can write to it
although i am not sure how to exactly implement that one
Huh
what huh
i wont think of a system just for you in detail, youll have to serialize your objects representing your game entities or the client unique information of those objects into some sort of string with pickle for example
and then send them to the server
Except not pickle, pickle isn't safe
some sort of serialization
Anyone here use Dash much?
Well, anyone with some Flask/Dash experience and has some time to explain a few things to me using my nearly working dash app as an example, if you wanna DM me that would be super awesome.
Code is as follows:
https://pastebin.com/iQ0vBBqF
hey anybody have some experience with sockets threading??
import logging
import socket
import _thread
import sys
log = logging.getLogger('udp_server1')
def udp_server1(host='10.10.156.180', port=7001):
print('start')
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
log.info("Listening on udp %s:%s" % (host, port))
s.bind((host, port))
tcphost = '192.168.1.133'
BUFFER_SIZE = 1024
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4, TCP
sock.bind((tcphost, port))
sock.listen(1)
print('Listening Till1')
while True:
conn, address = sock.accept()
(data1, addr) = s.recvfrom(128*1024)
conn.send(data1)
conn.close()
print('7001_', data1)
yield data1
def udp_server2(host='10.10.156.180', port=7002):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
log.info("Listening on udp %s:%s" % (host, port))
s.bind((host, port))
tcphost = '192.168.1.133'
BUFFER_SIZE = 1024
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4, TCP
sock.bind((tcphost, port))
sock.listen(1)
print('Listening Till2')
while True:
conn, address = sock.accept()
(data2, addr) = s.recvfrom(128*1024)
conn.send(data2)
conn.close()
print('7002_', data2)
yield data2
while 1:
_thread.start_new_thread( udp_server1, ('192.168.1.133', 7001, ) )
_thread.start_new_thread( udp_server2, ('192.168.1.133', 7002, ) )
not getting any errors
but its not running the function...
@cobalt valve your "while 1" is going to make it try to start hundreds of threads that won't be able to get the socket, and it seems like the threads never get a chance to run because the main thread is holding the GIL. Consider using the threading module and its join method instead. Also, your thread functions can't be generators (no yield statement), what are you trying to do with that? I'm on my way to bed, but I can maybe help you tomorrow
!tag ask
!tag get ask
Asking good questions will yield a much higher chance of a quick response:
β’ Don't ask to ask your question, just go ahead and tell us your problem.
β’ Try to solve the problem on your own first, we're not going to write code for you.
β’ Show us the code you've tried and any errors or unexpected results it's giving
β’ Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
@quartz maple ^
(As i mentioned, I'm on my way to bed, but if you just ask your question someone might be able to help you with it tonight or tomorrow)
@polar wasp let me know when you up again...ill check what happens if i remove the yield...
@quartz maple sorry man went to bed... i can try...shoot when you ready
Any form of Testing tips anyone can reccommend?
for Smoke testing a web application?
@polar wasp Wat
That was my question, to ask "can you help me with sockets"
don't tell me to use the ask thing
if the person was available i would have refered more info
but they weren't so it's not worth my time
@quartz maple I think we've talked to you about your attitude a couple times now, but that's simply not how you treat people you want help from.
By not actually posting your question, you're just wasting everyone else's time instead. If you're so intent on getting an answer, ask the actual question. And remember to provide a code example and information on what you've done to solve your problem.
Nobody is going to go "Yes I can sockets" and wait a few hours for you to post your question.
Hello, I was wondering if someone could help me
I cant seem to find an element on a website that I want to use in selenium
And when I go into the chrome element finder, nothing appears
Does this have anything to do with it having to use adobe flash player
probably
flash is flash, as far as HTML is concerned it's just a single media element without anything in particular inside it
So selenium isnt an option then?
do you have any experience in pyautogui?
no, sorry
Ok, np, thanks for the assistance
apparently there is a flash selenium https://code.google.com/archive/p/flash-selenium/
no browser inspector for flash elements though, so you're going to have to find what you're looking for the hard way
why the heck does beautifulsoup documentation suck so much
whats wrong with it
i can never figure out what attribute it is that i need for a given thing
they are all similarly worded and don't give you any context
like what?
https://www.baseball-reference.com/players/m/mayswi01.shtml i'm trying to get all the strings under <ul id="bling">
and everything i try doesn't work
children, descendants, next elements
desc = [x.string for x in testsoup.find(id='bling').children]
i spent like 15min on this alone
How do I :
Create and bind to a Unix socket file, myproject.sock, within our project directory. We'll set an umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access
@brave mantle I actually asked the proper thing a bit ago. I didn't know what code to put into the file, so that's why I asked.
@quartz maple if you read forwards in the DigitalOcean tutorial... it tells you
I am working through the Flask Mega-Tutorial and am running into an issue where my web app won't precess a 404 or 505 page and instead takes me to a defualt page stating that the connection has been reset. Is there anyone here who could possibly help me out with this?
@neat nest no it doesnt ffs
it doesnt tell me how to create a socket file.
I've done everything else.
And as far as i know i've done it correctly.
But im stuck on that bit ^
@plucky trellis Woudl you like to see my .service file
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app```????????
well that error is probably what you should lead with, then
Well would you be willing to help me ammend the error?
if not me then someone will be I'm sure
[Unit]
Description=Gunicorn instance to serve inte.ca site
After=network.target
[Service]
User=inteca-webmaster
Group=www-data
WorkingDirectory=/var/wwww/main/site
Environment="PATH=/var/www/main/site/site-env/bin"
ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:site$
[Install]
WantedBy=multi-user.target
thats my .service @neat nest
Well
Its not gonna be called myproject is it
β site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: ena
Active: failed (Result: exit-code) since Sat 2018-07-28 04:48:17 UTC; 28s ago
Process: 26850 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3
Main PID: 26850 (code=exited, status=210/CHROOT)
Jul 28 04:48:17 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site
Jul 28 04:48:17 KCWS systemd[1]: site.service: Main process exited, code=exited,
Jul 28 04:48:17 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
lines 1-10/10 (END)...skipping...
β site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2018-07-28 04:48:17 UTC; 28s ago
Process: 26850 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:site.sock -m 007 wsgi:app (code=exited, status=210/CHROOT)
Main PID: 26850 (code=exited, status=210/CHROOT)
Jul 28 04:48:17 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/CHROOT
Jul 28 04:48:17 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
its the exact same its just to my
filenams
well it looks like the 210/CHROOT is pointing to something, but I don't know systemd well enough to tell you what. possibly a directory permissions issue?
?
ExcecStart is weird tho
because the wsgi is in the main project folder
@neat nest
yeah? it's in your WorkingDirectory
so where am i going wron?
well, like I said, I could not tell you for sure, but I would suspect a directory permissions issue
so
does the site.sock file get generated
or do i have to create it
because idk where it goes
or what to put in it
I imagine the socket file is generated and used automatically
I do not know what is causing your error. I would wait until someone with relevant experience sees or present your issue to one of our #315249263103967242 that have more generalized Linux support
you said hello and left?
it doesn't even look like you visited Code Monkeys
for someone trying to solve a problem you seem strongly opposed to seeking help
@quartz maple You probably need to chmod or chown the site project files so that gunicorn can actually read them
I'll leave it as an exercise to you to figure out how to do that
Anyone know django here?
I'm sure many people do! you might be better served just asking your question
Resource for learning it?
the official tutorial is pretty good: https://docs.djangoproject.com/en/2.0/intro/tutorial01/
Two Scoops is very reputable as well
@brave mantle link pls
Sorry, I'm in a car currently, but I'm sure you can Google "two scoops Django"
ok
Hi everyone! Somebody who know Django? I have a little problem. I have a star rating in my project from django-star-ratings. In this moment i need to have a top 10 Voting Boks. I try do create a view based from Ratings but it's not working. Somebody know how to fix it?:|
Here is my model class https://pastebin.com/VPe9s0sF and my views https://pastebin.com/0eUN1B02
Hi all, I'm working through the Django tutorial and I've just got to the part with models. I'm having some difficulty getting my head around them - would anyone have the time to sit down and explain it to me clearly or point me in the direction of a decent tutorial video that goes into more depth than the tutorial?
Okay, nevermind, I fixed it. π
@reef sun I know about a good tutorial in youtube. It's from HTC - https://www.youtube.com/watch?v=QKH164mcdYk&list=PLjIu7NinqwsLmiOkCzy9ZYGQxQzw-304O&index=1
Learn Django 2.0 with PollMe 1 - Install Django and Create Project Learn how to build python powered web applications using Django, a powerful web framework ...
in my opinion, the best tutorial on Django on yt π
Cheers @native tide
π
Hello, I'm having a issue with flask and dynamic forms, can someone help me?
I created a subclass of a form inside a view. I have to grab information online via json, and then display the forms using the name/ID that the json file gives me. I'm looping through json and appending to a list StringFields('id'). This creates a bunch of UnboundFields. So far so good, but I cant display them using Jinja. If i just loop through the list and call the field, it display something like <UnboundField(StringField, ('SKU : ',), {})>... If I use form.label() it gives me an error: UndefinedError: 'wtforms.fields.core.UnboundField object' has no attribute 'label'.
This is inside the view
Template ^
Displaying only repr of the form
I know a bit about the bind() method but I dont know how to use it in my case
you should maybe contact him before it's midnight where he lives
also I'm certain you can provide more detail than "chmod"
can you help me with chmod?
not sure what chmod has to do with web development, nor general python help altogether - maybe ask your full question in one of the off-topic channels
It has alot to do with it....
such as..?
It's relevant
as its in the tutorial based on Flask
well
it was suggested anyway
@tame viper
i'm not gonna go to off-topic channel just to talk about chmod then come back here and talk on the same sort of topic relating to the thing i am having issues with
It was suggested anyway by an admin
So
if you're talking about me, I've told you multiple times to ask better questions
there's no excuse for this
hey guys, i wrote a custom script in flask for the page I want to refresh. It works fine on the same browser but doesn't work across browsers, does any one know why?
<script>
window.setInterval(function(){
if(localStorage.update == "1"){
localStorage.update = "0";
window.location.reload(true);
}
}, 100);
</script>
{% endblock %}
So this is the page that is being refresh, it is activated when I press a button on the other page.
Updating the page to get an update of the database table basically.
Does this has anything to do with cookies? I don't think so as I inspect the source code and it simply jquery to me, unrelated to cookies. I checked the console, no errors and it works on the same browser, just not across different browsers; it doesn't refresh.
maybe the refresh command is the problem, does anyone know any alternative function to that's able to refresh across all different browsers?
Update: I just tried incognito mode and it appears to be the case for chrome, that this is related to sessions and cookies perhaps. guessing it has to do with local storage.
So in this moment i need to do one thing
I have my book_types (CHOICES)
and a view
and in my template i have something like this now
In this moment it looks like this
I try to do something like this
when user click on the type (Number 1-Biografia), he was see a book list with only this types
If there is not a books with this type, he see 404 or something like this
I don't know how to do this. Somebody can explain me or something ?
look up making post requests with aiohttp
aiohttp is a d.py dependency so you have it already
@neat nest Its just a mess of crap
...?
@neat nest the docs don't mention anything about image useage
API Status
Status for the API can be found at status.imgur.com!
Getting Started
Imgur's API exposes the entire Imgur infrastructure via a standardized programmatic interface. Using Imgur's API, you can do just about anything you can do on imgur.com, while using your programmi...
I would like to use that
But it won't work with async
uhh any URL will work with async if you use aiohttp
No i mean
it looks like the Imgur API is pretty clear on how to interact with it
I can't use that API
aiohttp can make POST requests with all that information
aiohttp is basically requests but async
@tame viper I got confused
But it looks complicated
Why should i have to generate tokens?
the imgur API looks complicated???
I can confirm at least one of these things :P
There must be a rest API tutorial out there though
are there any good resources for getting started with the YouTube api?
Try some docs @narrow zealot
Anyone know this error, getting sqlalchemy_utils.exceptions.ImproperlyConfigured: βcryptographyβ is required to use EncryptedType using flask and sqlalchemy
a blind guess would be that you need to install the cryptography package with pip?
EncryptedType needs Cryptography library in order to work. yup
Is it possible in Django to add a form for a different (related) object under a detailview?
I've got a school group detailview that I'd like to have a form under to add an assignment to the group
Would I just use a form mixin?
@native tide what is your problem
@grand badge I Fix it yesterday, but thanks for asking :D
this is my code for the login form
def login():
"""Log user in"""
# Forget any user_id
session.clear()
# User reached route via POST (as by submitting a form via POST)
if request.method == "POST":
# Ensure username was submitted
if not request.form.get("username"):
return apology("must provide username", 403)
# Ensure password was submitted
elif not request.form.get("password"):
return apology("must provide password", 403)
# Query database for username
rows = db.execute("SELECT * FROM users WHERE username = :username",
username=request.form.get("username"))
# Ensure username exists and password is correct
if len(rows) != 1 or not check_password_hash(rows[0]["hash"], request.form.get("password")):
return apology("invalid username and/or password", 403)
# Remember which user has logged in
session["user_id"] = rows[0]["id"]
# Redirect user to home page
return redirect("/")
# User reached route via GET (as by clicking a link or via redirect)
else:
return render_template("login.html")```
Whenever I enter invalid user/pass combo I am getting this error: TypeError: get_bind() got an unexpected keyword argument 'username'. instead of returning the invalid user/pass 403 page
any ideas why?
no issues when typing just username or just password. only getting error when typing in both
this is sql alchemy right?
it was a syntax error
a TypeError is not a SyntaxError
if you're using SQLAlchemy, why are you writing SQL yourself, though?
Hey its possible to use a string as a variable in Jinja? For example if I create a new dynamic field with setattr like, setattr(BaseForm, 'id', StringField('name'), this ID at the moment is unknown to me, because it comes from another server. I need to render it but the only way I can know the ids is if I pass a list of IDs to the template, and loop through it to find each ID. What I tried and failed is to loop in the template and use the ids like: form.ID().
if this makes sense
{% for id in list_of_ids %}
{{ form.id.label() }}
{{ form.id() }}{% endfor %}
list_of_ids is a list of strings
What is the best framework for web development?
for python? flask - django
I met with opinion from other people's that's django is worst than Flask. It was True? ;x
@native tide flask is generally considered easier for begginers
Oh, okay. I understand. Meaby when i have much more time i take closer with Flask. In this moment only Django.
@native tide If you already know Django i see no reason to not continue with it
@shrewd sand Only just to see difference :d
@native tide you can't really say one framework is worse than another framework. Flask and Django can make you the same end product. I guess its based on preference
Django is a batteries included framework while flask makes you choose the batteries you want with your project
(No you canβt thatβs a bad idea Juan)
I'm having issues with Sockets and what content I am supposed to put in a .sock file. I'm not sure what it means in the tutorial i'm following by We will tell it to start 3 worker processes (adjust this as necessary). We will also tell it to create and bind to a Unix socket file within our project directory called myproject.sock. We'll set a umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access. Finally, we need to pass in the WSGI entry point file name and the Python callable within:.
``[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
Environment="PATH=/home/sammy/myproject/myprojectenv/bin"
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
I have setup my.service`` file.
However, it seems this bit: ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind is what is causing errors.
had the error changed since the last time you provided it in this channel? if not, Gdude and I still believe it to be an issue with your directory permissions. make sure it's accessible to the user running the process
you don't need to put anything in the sock file, as the tutorial says, it will be created for you
okay well if it is
then, whats the command to change that?
the user is inteca-webmaster
and it was created for this
i didn;t realise i was supposed to use a non-root user
otherwise i would just use root
til i got evverything setup properly
no the error hasnt changed. but im restating my issue as i got in trouble for nt pproviding enough info
so there you go..
chmod and chown are standard permission manipulation commands, I would look into them
also the User=sammy makes me think that the user isn't inteca-webmaster like you say
thats from the tutorial
as i said
im not on my usual omputer
dont ave access to my vps atm
you don't have access to the system you're seeking help for?
seems like a weird time to ask for help with it if you're not using it
but I guess you don't need to be on it to read about file permissions
good luck :+1:
whtt exactly do yu suggest i look for?
I dunno why everyone think Flask is easier for beginners, it seems like Django is to me
Django might seem more complex because it has more "stuff" packed in it, but without some solid class design, project management and understanding what extensions you need, you won't get very far in Flask - whereas with Django you can get a site up and running quickly and even takes care of the DB for ya
I think the notion that it's easier lies in the fact that you can produce your first barebones web service in minutes, not that it can achieve the same level of baseline functionality with minimal effort
Django is certainly much easier in the sense that it handles lots of work and design for you in stages of development beyond the very earliest
I think people don't recommend django to beginners is that a lot of things can be confusing at first. Flask is a bit more easy to understand. I started out with Flask and liked it but because of the many choices of databases and other stuff, I started learning django.
yes, the main difference lies not in the difficulty of the framework but in the approach
that's why I think django and flask are not competing, but complementary
Django seems more suited for the top-down approach, while Flask is made for the bottom up strategy
how do i give chmod perms to a specific user?
``
β site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-08-01 10:28:21 UTC; 1min 53s ago
Process: 920 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:sit
Main PID: 920 (code=exited, status=210/CHROOT)
Aug 01 10:28:21 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Aug 01 10:28:21 KCWS systemd[920]: site.service: Failed at step CHROOT spawning /var/www/main
Aug 01 10:28:21 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/C
Aug 01 10:28:21 KCWS systemd[1]: site.service: Unit entered failed state.
Aug 01 10:28:21 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
~
``
Use three back ticks for a code block @quartz maple
I tried to yeah,
I mean I nearly did three but two seemed to look better
I know to use three
I can't see a code block, maybe it's cuz I'm on mobile?
I can see a code block either
I used two code blocks as it looks better
Thst is when it comes to that specific one
@quartz maple you've asked this question here before, and at least three people have told you that this isn't the right channel for that. you've also been told twice by Lucy exactly what to do, would you like me to show you again to save you from scrolling up a tiny bit? here you go.
@tame viper mate I was kicked
for a reason
I canβt scroll up chances are, when I was kicked my messages were deleted
Jesus Christ of course for a reason
and you're still not researching chmod and chown. shoo, get to it
so then try it?
so then stop asking questions when you're not in a state to attempt the answers. did you not try beforehand, when you researched chmod and chown?
I researched them I didnβt attempt the thing I found as I hadnβt found it, but then I did and I wasnβt on my pc to execute it
Because I just got off.
so then if you did find it, why are you still asking here?
Because I posted the error message before I did?
but you found the answer already.. yes?
Iβm not sure yet if it works, it works if it doesnβt
Then itβs something elseβs
so then why are you asking if you don't even know it works yet? if it does work, you'd just be wasting our time. (but you're already doing enough of that)
Yeah okay.
Where do I chown to?
Exactly
And if it isnβt the right channel, why does it relate to web development?
a permission problem is not really related to web development, although it seems like we've already given you some keywords here.
but it doesn't relate to web development? chmod and chown are questions about unix-like permission management. here's your answer, which you've already been given btw
Okay
there's a linux discord where you might get help with chown or chmod, I can link you if you want.
well it might be better to ask them these kinds of linux questions
we're really just here to help with python
or other webdev questions
I know that, but it is sort of for Python, once I get past this error
It goes to flask
once you get past that error, perhaps it is python. it's still not currently python though
and once you get past it, you're welcome to come back here :P
yup
Iβve never heard of gunicorn either.
I followed a tutorial
well you should probably try to gain a deeper understanding of the components that make up your application
following tutorials blindly without understanding what you're doing will lead you to places like this.
Well Iβm new to flask, and I was told to use gunicorn with it otherwise I donβt know.
I donβt know whatβs it used for.
I just wanna make it use port 80.
in Django how to change permissions for a model with a OneToOne relationship to a User model?
currently I've got this -
`class Teacher(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
class Meta:
permissions = (
('create_assignment', "Create an Assignment object"),
('change_assignment', "Update an Assignment object"),
('delete_assignment', "Delete an Assignment object")
)`
views.py class AssignmentCreateView(PermissionRequiredMixin, CreateView): permission_required = ('create_assignment', 'change_assignment', 'delete_assignment') model = Assignment form_class = NewAssignmentForm
i'm not sure if I should change Teacher to an AbstractUser or if there's a different way of going about it
i've already run manage.py migrate so the permission are in the db
I'd like it so that only users with a related teacher model can create assignment objects
Does anyone here know how to write/debug javascript?
I need help debugging my chrome extension, but I'm not able to open a developer tool window in chrome
I posted the full details in #ot1-this-regex-is-impossible
{% block navbar %}
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#myPage ">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="#about">Inicio</a></li>
<li><a href="#services">Lista de Material</a></li>
<li><a href="#portfolio">InstalaΓ§Γ΅es</a></li>
<li><a href="#pricing">MatrΓcula</a></li>
<li><a href="#contact">Contato</a></li>
</ul>
</div>
</div>
</nav>
<div class="jumbotron text-center">
<h1>ColΓ©gio Intellectus</h1>
<img src="logo.png">
</div>
{% endblock %}
help
Why this {% endblock %} is on the page?
@native tide check the template that uses this
there might be an extra {% endblock %} there
okay cool :D
while i'm here, does anyone have any idea for flask projects i can do? i'd prefer it to be something useful that anyone can use ^-^
@tame viper , This a school website i'm training to do, but i'm too dumb. 
hey, just keep trying. you'll get there :D
@tame viper a basketball api
elaborate.
:D
(that was a verb, not an adjective. my bad)
oh idk tbh i was just meming
haha
if you can think of a good enough idea with that, i'll do it
i just want something to do
HI
I need a pro in WebDesign
It is possible to put an entire card inside a label?
Is it correct?*
<div class="card">
<label class="m-0" for="pizza_gigante_idProduto">
<div class="p-1 p-md-2 card-header text-center bg-warning">
<strong>
<input type="radio" name="pizza_tamanho" id="pizza_gigante_idProduto" value="gigante">
Gigante
</strong>
</div>
<div class="p-1 p-md-2 card-body text-center">
R$ 27,99
</div>
</label>
</div>
So I can click anywhere on the card
To activate the radio
Hi, I'm trying to run a flask webapp(locally) that takes a CSV file and turns it into a QIF file for GNUcash. the file does get uploaded and put into the correct folder but it returns an internal server error. I think it has to do with how flask handles POST requests or it is something with my return function. Raboflask.py - https://pastebin.com/PeWQ3G1M Log: https://pastebin.com/eXUZ7t6m. Could anybody point me in the right direction?
Hey, is it possible to populate a WTForm MultipleFileField field with known file paths? ex: form.pictures.data = ['full/file/path.jpg', 'full/file/path2.jpg'].
And is it possible to get the full file path on the computer with this field?
@solar glen I can't check the code throughly, but have you set the content type properly? Also make sure you're handling bytes, not unicode string types
Anyone knows why I'm getting this error?
https://cdn.discordapp.com/attachments/159041895077642251/474611925821554709/unknown.png
Hello! is there anyone who is good at facebook pixel tracking and help me please?
!t ask
Asking good questions will yield a much higher chance of a quick response:
β’ Don't ask to ask your question, just go ahead and tell us your problem.
β’ Try to solve the problem on your own first, we're not going to write code for you.
β’ Show us the code you've tried and any errors or unexpected results it's giving
β’ Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
Thanks, I am now on Django Ecommerce project and FB tracking has already been partially implemented, but no dollar amounts are being sent.
I need to update existing code to send dollar amount.
I am new to FB pixel tracking and don't know what I have to do.
after googling, I saw this example. fbq('track', 'Purchase', {'value':'9.99','currency':'USD'});
I am guessing this is what I have to do. but not sure
This is existing code on my purchase.html
{% if facebook_pixel_id %}
<script>
fbq('track', 'Purchase');
</script>
{% endif %}
Should I paste my facebook-pixel.py also ?
hello?
please be patient, your question will get answered when someone who can help is available
okay, thanks
Can i use django framework to build personal website ?
yes.

π
@queen needle thanks for your reply! π the file that is uploaded is encoded as utf-8 but i will look into it more thanks!
Is there a way to block someone from being able to see a flask url when it is only meant to be pulled by the javascript in the frontend, the information passed is meant to be hidden within the game, but I'm not sure how I would render the image from the data in the backend without another player to be able to simply pull that information by typing a url
you'd either need a mechanism to verify that the frontend is making the request or to encrypt the response
I believed so
in either case, due to JS's rather transparent nature, you're essentially just obfuscating
a determined enough user probably won't find it difficult to spoof or crack whatever mechanism you use
the only surefire way to make sure they don't get the data is to structure your application so that it's not sent, but you mentioned that seems impossible
if you share some of your concept, maybe others could weigh in
my concept being what I'm doing?
sure, at least enough that you think people could help determine how you might limit the data offered to the end user
okay, I'll try, am I allowed to post an example of what I'm doing as a website?
or would that be classed as advertising?
should be fine
will be fine, I should say. I'm an admin giving you explicit permission
okay, minichotagames.ml should build your hand and if you after, happen to go to minichotagames.ml/image_movement/.card{x}
1 would correspond to player ones first card
up to 4 being all player ones cards
and 5-8 being player twos cards
this is obviously not good as its simple enough to access such data
ah, I see
so you don't need to provide both players with all the data pertaining to the other player, it just happens to be publicly accessible at the moment
what?
you made it sound like you needed the frontend to always be able to get everyone's information, but that doesn't seem like the case to me
really?
the server should be doing the work of managing the rules, not the client
did you also happen to test the basic functionality of the program to furthur prove your theory?
it's less of a theory and more of a recommendation
is there a reason that client 1 always needs access to client 2's cards? or could the server determine at its discretion when to reveal that information?
truthfully, I'm not sure, I wouldn't think so
except when, during the playing phase of the game that exists between the two players that the other player would have to load the other players card as its played
in the actual game, their hands would be hidden
to each other till such an event occurs
so in that event, they should be making a request to the server to find out what card was played, assuming you're doing this entirely with HTTP endpoints
does that sound feasible?
yup
something like this in the javascript $('#div3').replaceWith() would ruin such a thing though, yes?
as you can view in the webpage
oh, is the card revealed when it's played or no? I admit I'm not testing your application at the moment because I'm on a phone and multitasking
well, as I haven't exactly made it multiplayer, it more or less moves it
but theoretically if they were hidden in the first place, they would be 'revealed'
as I have a sort of 'key'
keys = { 'card1': player1Choices[0], 'card2': player1Choices[1], 'card3': player1Choices[2], 'card4': player1Choices[3], 'card5': player2Choices[0], 'card6': player2Choices[1], 'card7': player2Choices[2], 'card8': player2Choices[3]}
this is what the flask endpoint is using to comprehend what card is pulled upon making a jquery ajax request
I'm afraid I don't follow
okay, above is something that updates a dictionary that the javascript uses
in this endpoint
def play(card): card = card.strip('.') Played.append(keys[card]) return str(keys[card])
the only important part is the return
also accessing this url happens to mess up the flow of the game as it appends to the 'Played' list
this is just making it so in the js I can type something like: python var card = $.ajax({ type: "GET", url: "/image_movement/.card1", async: false }).responseText;
and it will return player ones first card
this is more of a general comment on design, but it would also help mitigate some of your data hiding issues. my recommendation would be to have one /hand endpoint for this purpose, instead of an endpoint for every card. the clients would need to provide some token verifying which they were and then could recieve all the information they ought to at once
but doing so would change the difficulty of 'playing a card'
as I would have to find the index of the card, but I'll be fine, what kind of token do you speak of?
whenever the ajax request happens it inputs the token?
I believe this would work but if the player were to view the js file in the debugger window, they could easily access such a thing
sure but the player knowing their own token would only give them access to whatever information their client already has
I see
the token would be provided by the server to verify which client is which, you'd probably want to randomly generate them so they don't get reused
hmm, I don't see why that would be the case
the server would make them aware of which player they are and that should be enough information
hm
this seems difficult
what if the player were to trace the vars and find the token to the other player?
why would they have access to the other player's token?
well, thats what I'm finding hard to prevent
try accessing